[Qt-qml] Dummy model for QList<QObject*> model
Cornelius Hald
hald at icandy.de
Tue Sep 14 16:32:25 CEST 2010
On Tue, 2010-09-14 at 16:10 +0200, Stephen Kelly wrote:
> 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/
Thanks Steve, but then I'm having the same problem as with
QList<QObject*> models. In both cases they are accessed in a different
way compared with QML ListModels.
Maybe we could write a generic wrapper like, for example, ListModel<T>
that would expose all properties of the containing type T as roles. Not
sure if that is possible, though. It's just a couple of days since I'm
in Qt land :)
Anyways, I'll read your article - I probably can learn something.
Thanks!
Conny
More information about the Qt-qml
mailing list