[Qt-qml] Dummy model for QList<QObject*> model

Stephen Kelly steveire at gmail.com
Tue Sep 14 16:10:34 CEST 2010


Cornelius Hald wrote:

> Thanks! qmlRegisterType() helped with my own model (derived from
> QAbstractListModel). With QObjectListModel I'm still having a problem,
> because I don't understand how the roles are defined. From looking at
> the code and the comments it looks like only one role with the name
> "object" is defined. But then, how should I use it in QML?

Define Q_PROPERTIES and access them on the object.

delegate : Text { text: model.object.someProp; height : 20 }

I wrote something similar before but used the term 'data' instead of 
'object', so I used model.data.someProp.

http://steveire.wordpress.com/2010/02/19/qml-with-akonadi-or-how-to-use-
your-existing-model-view-design-with-qml/

All the best,

Steve.



More information about the Qt-qml mailing list