Important: Please read the Qt Code of Conduct -

QObjectList as model is not updated by Repeater when changing data of model!

  • Hi all,

    I try to use a QObjectList in C++ as model for a QML Repeater instance.
    If I add a new object to QObjectList in C++, the Repeater destroys all prior created items and creates new items.

    I think this is ugly because if the list has many objects and I add only one new object then all QML items instantiated by Repeater's delegate are destroyed and the created once again.

    But the main issue is that if I change only the content/data of a single object of QObjectList the Repeater does nothing - either destroy of all old elements nor update the single object.

    Currently I solved it by remove the last object, emit the listChanged() signal (then the Repeater is updated), append the last one again, emits listChanged() once again. That's double ugly!!

    Can I solve this by implementing my own model inherited from QAbstractListModel?

    Are there any other elements to visualize a model than Repeater? The background is that I load several visual informations (x, y, size) from a file and want to place it to e.g. a Rectangle.

    Thanks a lot for answers... I use Quick 1.1 with Qt 4.8.5.

Log in to reply