[Qt-qml] Repeater child count

Bo Thorsen bo at fioniasoftware.dk
Wed Sep 7 07:37:54 CEST 2011


Den 06-09-2011 13:49, Stephen Kelly skrev:
> 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.

Yes, I was convinced this was the case as well. I filed the report 
yesterday :)

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