Hi,
I'm exposing a QList<QObject*> property from C++ to QML. There I can
access it, for example, with the following code.
ListView {
anchors.fill: parent
model: myModel.dataObjects //dataObjects is QList<QQobject*>
delegate: Rectangle {
height: 25
width: 100
color: model.modelData.color
Text { text: model.modelData.name}
}
}
Now I've tried to put some dummy data in place to simulate the model if
the QML code is run without C++ backend. So I've created the following.
// dummydata/myModel.qml
import Qt 4.7
Item {
property alias dataObjects: listModel
ListModel {
id: listModel
ListElement {
name: "Dummy Peter"
color: "orange"
}
ListElement {
name: "Dummy Paul"
color: "yellow"
}
}
}
Unfortunately this is not working as expected. It only works if I remove
the "modelData" part from the delegate. E.g. the following works.
ListView {
anchors.fill: parent
model: myModel.dataObjects //dataObjects is QList<QQobject*>
delegate: Rectangle {
height: 25
width: 100
color: model.color // removed modelData
Text { text: model.name} // removed modelData
}
}
How can I create a dummy model that I can use as a drop-in replacement for my
QList<QObject*> model?
Thanks!
Conny
_______________________________________________
Qt-qml mailing list
[email protected]
http://lists.trolltech.com/mailman/listinfo/qt-qml