Created
December 25, 2014 16:21
-
-
Save M4rtinK/5eac64011483fb2aef8a to your computer and use it in GitHub Desktop.
Filling a Silica ComboBox from PyOtherSide - approximate untested example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import QtQuick 2.0 | |
import Sailfish.Silica 1.0 | |
import io.thp.pyotherside 1.0 | |
ComboBox { | |
width: 480 | |
label: "Foo Bar" | |
id: fooBox | |
property var dataModel : ListModel {} | |
Python { | |
id: py | |
Component.onCompleted: { | |
// Add the directory of this .qml file to the search path | |
addImportPath(Qt.resolvedUrl('.')); | |
// Import the main module and load the data | |
importModule('listmodel', function () { | |
py.call('listmodel.get_data', [], function(result) { | |
// Load the received data into the list model | |
for (var i=0; i<result.length; i++) { | |
dataModel.append(result[i]); | |
} | |
}); | |
}); | |
} | |
} | |
menu: ContextMenu { | |
Repeater { | |
model: fooBox.dataModel | |
MenuItem { | |
text: "Item #" + model.index | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment