[Qt-qml] Repeater child count

Stephen Kelly steveire at gmail.com
Tue Sep 6 13:49:04 CEST 2011


Bo Thorsen wrote:

> Hi all,
> 
> I don't understand this behaviour:
> 
> I have a QAbstractListModel subclass implemented in C++ and exported to
> the QML code.
> 
> The problem comes when I modify the contents of the model. Here is the
> QML code I'm testing with:
> 
> Item {
>      id: seatView
>      anchors.fill: parent
> 
>      onChildrenChanged: console.log("Children length " +
> seatView.children.length);
> 
>      Repeater {
>          objectName: "repeater"
>          model: handModel
>          Text { text: name }
>      }
> }
> 
> When I do a dataChanged(index(0), index(rowCount() - 1) or a reset() in
> the model, the number of children of the view grows. It actually grows
> with exactly rowCount() new children, but the old are still there. I
> have checked that rowCount() stays the same :)
> 
> Did I do something wrong here, or is this a bug? It certainly can't be
> right that the number of children in the view grows on data changes.
> Then I would have to stop using the model and just go with a hardcoded
> view.
> 
> My model is a simple list model subclass with only rowCount and data
> implemented. There is nothing odd in the code, AFAICS.
> 
> Bo Thorsen,
> Fionia Software.
> 

That's a bug you should file. From your description you should be able to 
create a standalone testcase.






More information about the Qt-qml mailing list