Op 13-11-2011 11:33, Johan Paul schreef:
> 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.
Not really. You can also append a QObjectList. Just make sure that you 
don't call append or insert more often than needed. You can use a scheme 
like I detailed here [1] to prevent making changes too often.
>>
>> Also as an aside (but related question), is using QObjectListModel with
>> threading safe?
Object or methods on objects that are not explicitly documented as 
thread save, should not be assumed to be be thread save.
>> Ie, am I allowed to use it outside of the main thread?
No, but you can use signals and slots to communicate in a thread save way.
>> 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.
Don't do that. Objects that interact with the GUI, need to live in the 
GUI thread. With Qt 2, that becomes a bit different, but for now, I 
guess you should stick to that adagium.

André

_______________________________________________
Qt-qml mailing list
Qt-qml@qt.nokia.com
http://lists.qt.nokia.com/mailman/listinfo/qt-qml

Reply via email to