In general Qt Quick (at least 1) is in general not very good with dynamically changing data models in List views.
And in any more complicated cases than showing a few static items in a QML List, I would go with exposing a QAbstractListModel to Qt Quick instead of the QList<QObject *> approach. http://doc.qt.nokia.com/latest/qdeclarativemodels.html#qabstractitemmodel Then, at least in theory, you have the possibility to efficiently change the content of your model asynchronously. Cheers, Johan > Hi, > > I was previously adding objects one-by-one... I tried updating > everything at once as you mentioned (ie. with QObjectList) and there was > no delay at all, which is awesome :) > However, doing this isn't really ideal in all cases -- for example, if I > asynchronously receive a bunch of objects I need to update the view > with, I'm stuck. > > Also as an aside (but related question), is using QObjectListModel with > threading safe? Ie, am I allowed to use it outside of the main thread? > If you try to move QObjectListModel into its own thread, you need to > register the QModelIndex object as a metatype, and after doing that, > things *seemed* to work fine, but I was wondering if anyone had a > concrete answer. > > Regards, > > Pris > > On Sun, Nov 13, 2011 at 4:05 AM, Andre Somers <[email protected] > <mailto:[email protected]>> wrote: > > Op 13-11-2011 7:29, Pris Matic schreef: > > Hiya, > > > > I've been using this class: > > https://qt.gitorious.org/qt-labs/qml-object-model to expose a list of > > QObject properties to a ListView. It works great until the number of > > objects in the ListView starts going up. I have about 70 objects > in my > > list view, each with maybe 10 properties (all QStrings or ints). My > > delegate isn't complicated, and ListView performance (ie. scrolling) > > is fluid. The issue is it takes forever for the ListView to load in > > the first place... upwards of 6-7 seconds on my dual core PC. This > > doesn't occur if you expose the data to the ListView through > > QVariant... in that case the data shows up almost immediately. Once > > the data is loaded, everything runs great. It also loads fine when > > there are less than 10-15 items. Has anyone else experienced this > when > > using a Qaim based model with ListView in QML? Are there any > workarounds? > > > How do you add the QObjects to the QObjectListModel? Do you do that > object-by-object, or do you set the whole list in one go using a > QObjectList? > > André > > _______________________________________________ > Qt-qml mailing list > [email protected] <mailto:[email protected]> > http://lists.qt.nokia.com/mailman/listinfo/qt-qml > > > > > _______________________________________________ > Qt-qml mailing list > [email protected] > http://lists.qt.nokia.com/mailman/listinfo/qt-qml _______________________________________________ Qt-qml mailing list [email protected] http://lists.qt.nokia.com/mailman/listinfo/qt-qml
