[Interest] Updating a model re-add everything in QML. How can i prevent that?

Bo Thorsen bo at fioniasoftware.dk
Thu Nov 8 10:34:16 CET 2012

Den 08-11-2012 01:33, Mark skrev:
> Hi,
> I have a models in C++ (a QStringList actually). In QML i'm displaying
> it using a repeater. Now when i remove some items from the end of the
> list (which happens quite a few times) then the entire list seems to
> go through the QML repeater again.
> What i want to do is put a QStringList in a QML Repeater (works), but
> when i remove items from the end i would like QML to be "smart" and
> also remove the items from the end and leave those that haven't
> changed. Thus not re-inserting all the items in the repeater when not
> needed.
> Is there some option to get that?

To do this you need a better model than a QStringList in Repeater. Take 
a look at QStringListModel instead. But if you just call setStringList() 
you won't see any improvement. You have to use insertRows and removeRows 

Bo Thorsen.

Come by my DevDays talk in Berlin - "Designing for testability". Learn how to build and run your unit tests with the Qt application.

Fionia Software - Qt experts for hire.

More information about the Interest mailing list