I'm trying to make program which uses Qt Kinetic Declarative UI: http://labs.trolltech.com/blogs/2009...eclarative-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++?

Qt Code:
  1. ListModel {
  2. id: ContactModel
  3. ListElement {
  4. name: "Bill Smith"
  5. number: "555 3264"
  6. }
  7. ListElement {
  8. name: "John Brown"
  9. number: "555 8426"
  10. }
  11. ListElement {
  12. name: "Sam Wise"
  13. number: "555 0473"
  14. }
  15. }
To copy to clipboard, switch view to plain text mode