[Qt-qml] Dummy model for QList<QObject*> model
Cornelius Hald
hald at icandy.de
Tue Sep 14 13:10:12 CEST 2010
Hi!
On Tue, 2010-09-14 at 01:00 +0200, michael.brasser at nokia.com wrote:
> Is the above the exact wording of the error message you are seeing (if so, what release version are you using)? If the objects in the list are QtObjects, I get the message "Cannot assign to non-existent property "name"", but as long as they are of a custom type that we've defined (in this case MyObject), with the corresponding custom properties, it all works as described for me (note that MyObject.qml needs to go in the root directory, rather than the dummydata directory). I'm happy to send you a tar of the files I'm testing with, if this is still something you want to pursue.
The error above is the error I receive from QtCreator. I noticed that I
can still execute the code with qmlviewer. So it looks like a QtCreator
issue. Still, I'm having the problem with the import of MyObject. For
some reason dummydata/myModel.qml can't find MyObject.qml. Not if I put
it into 'dummydata' and not if I put it into the parent folder (which is
not the root folder). I've tried different imports relative to
myModel.qml and relative to the component that uses myModel.qml, but
without success.
Anyways, I will not use the QList<> approach in my application because
of the .modelData issue. Still, if it is no problem for you, please send
me your example. I'm always curious :) Ah and I'm using Qt 4.7-rc1 on
Ubuntu taken from this[1] PPA.
> You'll need to register the QObjectListModel type to use it in a property, using qmlRegisterType<QObjectListModel>();
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?
Until I fully understand QObjectListModel I'll use my own
QAbstractListModels. But I hope I can switch eventually.
Thanks for all the help!
Conny
[1] https://edge.launchpad.net/~kubuntu-ppa/+archive/experimental
More information about the Qt-qml
mailing list