-
Bug
-
Resolution: Unresolved
-
P2: Important
-
None
-
5.15.2, 6.5.0
-
None
The Repeater item seems to behave weirdly when the model is updated (item added) in the Component.onCompleted of one of the delegates.
In such a case, delegates are later not destoryed when items are removed from the model, even though the Repeater itself is updated ( count changed, itemsRemoved signal sent, index of delegate is set to -1).
Note: is seems to work fine for ListView.
Minimal example:
ListModel {
id: itemsModel
}
Button {
anchors {
top: parent.top
right: parent.right
}
text: "Add first item"
onClicked: {
itemsModel.append({ "first": true });
}
}
Repeater {
model: itemsModel
delegate: Rectangle {
width: 100
height: 100
color: model.first ? "red" : "green"
Component.onCompleted: {
x = (index + 1) * 20;
y = (index + 1) * 20;
z = index;
if (model.first === true) {
// uncomment the lines to make it working
// Qt.callLater(() => {
itemsModel.append({ "first": false });
// });
}
}
Text {
text: index
}
MouseArea {
anchors.fill: parent
onClicked: {
itemsModel.remove(index);
}
}
}
}
Examples:
Delayed model update (working):

Instant model update (not working - bug):
