mirror of
https://github.com/thp/pyotherside.git
synced 2025-01-28 23:52:55 +08:00
2a79458c68
Also update examples to use the new feature.
42 lines
985 B
QML
42 lines
985 B
QML
import QtQuick 2.0
|
|
import io.thp.pyotherside 1.0
|
|
|
|
Rectangle {
|
|
color: 'black'
|
|
width: 400
|
|
height: 400
|
|
|
|
ListView {
|
|
anchors.fill: parent
|
|
|
|
model: ListModel {
|
|
id: listModel
|
|
}
|
|
|
|
delegate: Text {
|
|
// Both "name" and "team" are taken from the model
|
|
text: name
|
|
color: team
|
|
}
|
|
}
|
|
|
|
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++) {
|
|
listModel.append(result[i]);
|
|
}
|
|
});
|
|
});
|
|
}
|
|
}
|
|
}
|