[Qt-qml] Repeater child count

Bo Thorsen bo at fioniasoftware.dk
Tue Sep 6 09:08:53 CEST 2011


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.

-- 

Expert Qt and C++ developer for hire
Contact me if you need expert Qt help
http://www.fioniasoftware.dk


More information about the Qt-qml mailing list