How to access QList<QObject*> items in QML
-
I pass QList<QObject*> from Qt to QML:
context->setContextProperty("listViewModel", QVariant::fromValue(data));And then use it as Listview's model to fill the ListView.
All that works correctly.I also want to access model's items from other places, not just from ListView
It should be possible to do it like that (for first item): listViewModel.get(0);But I get the error:
TypeError: Result of expression 'listViewModel.get' [undefined] is not a function. -
Hi,
The initial release of QML for the most part focused on list/model support as a source of data for views. You can track issue "QTBUG-14986":http://bugreports.qt.nokia.com/browse/QTBUG-14986 for full list manipulation support from within QML.
Regards,
Michael -
You can see the how to access the list model element in QML.
You should check the below link.
http://doc.qt.nokia.com/4.7-snapshot/qml-listmodel.html
Best regards,
-
[quote author="qtrahul" date="1292918337"]You can see the how to access the list model element in QML.
You should check the below link.
http://doc.qt.nokia.com/4.7-snapshot/qml-listmodel.html
Best regards,[/quote]
Rahul,
Please read the query and reply accordingly.
-
[quote author="borut123" date="1345498136"]
No other way. Try QAbstractListModel, it's not so difficult as it sounds.[/quote]Its not difficult. But for doing simple things like this why should we sub class one more class and deal with defining properties, functions etc, etc. This is how I feel. I'm alread having a tough time dealing with poniters (Esp. deleting QThread objects). So I don't want to create one more class. :-(