PDA

View Full Version : Qt Kinetic: adding items to list



Diph
4th November 2009, 13:32
I'm trying to make program which uses Qt Kinetic Declarative UI: http://labs.trolltech.com/blogs/2009/05/13/qt-declarative-ui/

I've been trying to add items to ListView from C++ but it doesn't work. Static QML ListModel works just fine. I can't find the API online but it says you can pass C++ data models to QML.


QAbstractItemModel provides the roles set via the QAbstractItemModel::setRoleNames() method.
QStringList provides the contents of the list via the modelData role.
QList<QObject*> provides the properties of the objects in the list as roles.

For example how do I make this model in C++ so I can add new elements in C++?


ListModel {
id: ContactModel
ListElement {
name: "Bill Smith"
number: "555 3264"
}
ListElement {
name: "John Brown"
number: "555 8426"
}
ListElement {
name: "Sam Wise"
number: "555 0473"
}
}

Diph
10th November 2009, 08:27
Any ideas? I have tried different solutions but nothing works.