| 1 |
import QtQuick 2.0 |
| 2 |
import io.thp.pyotherside 1.0 |
| 3 |
|
| 4 |
Rectangle { |
| 5 |
color: 'black' |
| 6 |
width: 400 |
| 7 |
height: 400 |
| 8 |
|
| 9 |
ListView { |
| 10 |
anchors.fill: parent |
| 11 |
|
| 12 |
model: ListModel { |
| 13 |
id: listModel |
| 14 |
} |
| 15 |
|
| 16 |
delegate: Text { |
| 17 |
// Both "name" and "team" are taken from the model |
| 18 |
text: name |
| 19 |
color: team |
| 20 |
} |
| 21 |
} |
| 22 |
|
| 23 |
Python { |
| 24 |
id: py |
| 25 |
|
| 26 |
Component.onCompleted: { |
| 27 |
// Add the directory of this .qml file to the search path |
| 28 |
addImportPath(Qt.resolvedUrl('.')); |
| 29 |
|
| 30 |
// Import the main module and load the data |
| 31 |
importModule('listmodel', function () { |
| 32 |
py.call('listmodel.get_data', [], function(result) { |
| 33 |
// Load the received data into the list model |
| 34 |
for (var i=0; i<result.length; i++) { |
| 35 |
listModel.append(result[i]); |
| 36 |
} |
| 37 |
}); |
| 38 |
}); |
| 39 |
} |
| 40 |
} |
| 41 |
} |