[Qt-qml] dynamically updatable model in QML ListView
vineeth
nvineeth at gmail.com
Fri May 20 12:26:53 CEST 2011
I could get this working using :
declView->rootContext()->setContextProperty(...)
to update the model variable used in QML ListBiew, but I think this involves
unnecessary computation.
A more optimal way will be to get a reference to the model of the ListView
and call append on it.
There is a example of this in :
C:\QtSDK\Examples\4.7\declarative\modelviews\listview\dynamiclist\qml\ and I
need to do the same using C++ backend.
Thanks all for the kind reply.
--vineeth
On Fri, May 20, 2011 at 3:18 PM, Pelle Johnsen <pelle.johnsen at gmail.com>wrote:
> If using ListModel you don't need to reassign the whole model (which is bad
> as it requires ListView to recreate or at least reinitialize all delegates).
>
> ListModel has methods for updating the model: append, insert, move, remove,
> clear. I'm guessing it's using the item views mechanism under the hood to
> inform ListView of the changes.
>
> -Pelle
>
>
> On Fri, May 20, 2011 at 11:26 AM, Thomas Ganshorn <mailings at novaimages.de>wrote:
>
>> i read once that you have to reassign the modell to the listview.
>>
>> Not quite good implementation but there seems to be no other solution
>> unless you want to write your own qaim model (wich is something i really
>> hate and would always avoid if possible)
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.qt.nokia.com/pipermail/qt-qml/attachments/20110520/eb045b29/attachment.html
More information about the Qt-qml
mailing list