Details
-
Bug
-
Resolution: Duplicate
-
P2: Important
-
None
-
5.15.15, 6.2.10, 6.5.3, 6.6.0
-
Windows 10 22H2, MSVC 2019 x64
Description
Code
ApplicationWindow { id: root width: 640 height: 480 visible: true header: Row { Button { text: "Clear" onClicked: model.resetData(0) // Calls (begin|end)ResetModel() } Button { text: "Reset Data" onClicked: model.resetData(100) // Calls (begin|end)ResetModel() } Button { text: "Prepend Data" onClicked: model.prependData(100) // Calls (begin|end)InsertRows() } } MyModel { id: model } ListView { id: view width: 400 height: 400 model: model onCountChanged: positionViewAtEnd() delegate: Rectangle { id: delegate required property int index required property string display width: view.width height: view.height / 10 color: (index % 2) ? "beige" : "brown" Text { anchors.centerIn: parent font.pixelSize: 15 color: (delegate.index % 2) ? "black" : "white" text: delegate.display } Component.onCompleted: console.log("New:", display) Component.onDestruction: console.log("Destroyed:", display) } } }
Steps to Reproduce
- Build and run the attached project
- Click "Reset Data" a few times
- Click "Clear"
- Click "Prepend Data"
Outcomes
- At step #2, 21 delegates are created each click (reasonably expected)
- At step #4, 117 delegates are created on the first click (very unexpected)
Notes
- This example demonstrates the example using ListView, but it also affects other views (e.g. GridView)
Attachments
Issue Links
- duplicates
-
QTBUG-116723 TableView + TableModel discards every delegate with every update
- Closed