Details
-
Bug
-
Resolution: Unresolved
-
P2: Important
-
None
-
6.4.1
-
None
-
any
Description
When a view displaying from a DelegateModel is changed, the delegates sometimes have lingering properties from the previous positioner, in some cases can't be positioned at all., producing wrong or outright no output. Here is a snipped to reproduce the issue:
property var comps: [ c1, c2, c3, c4 ] property var names: [ "hlist", "vlist", "row", "col" ] property int which: 0 Column { spacing: 10 Button { text: names[which] onClicked: which = (which + 1) % comps.length } Loader { sourceComponent: comps[which] } } DelegateModel { id: dm model: 10 delegate: Rectangle { width: 50; height: 50; color: "red" DelegateModel.inPersistedItems: false } } component List: ListView { width: contentItem.childrenRect.width height: contentItem.childrenRect.height reuseItems: false model: dm } readonly property Component c1: List { orientation: ListView.Horizontal } readonly property Component c2: List { orientation: ListView.Vertical } readonly property Component c3: Row { Repeater { model: dm } } readonly property Component c4: Column { Repeater { model: dm } }
As the button is clicked, the loader creates a different representation for the model, but the result is inconsistent and rarely correct.
Sometimes it would successfully switch between hlist and vlist, but sometimes items will be diagonal, with the dimension expected to be 0 lingering from the previous orientation. Switching between row and column is even worse - the result, if any is bugged, items flicker in and out of existence, or some items are missing, and there's excessive warning in the console:
QQuickItem::stackAfter: Cannot stack QQuickRectangle(0x1b060bdb810, parent=0x1b060bd84f0, geometry=0,0 50x50) after QQuickRectangle(0x1b060bda4d0), which must be a sibling QQuickItem::stackAfter: Cannot stack QQuickRectangle(0x1b060bdb110, parent=0x1b060bd84f0, geometry=0,0 50x50) after QQuickRectangle(0x1b060bdb810), which must be a sibling QQuickItem::stackAfter: Cannot stack QQuickRectangle(0x1b060bdbab0, parent=0x1b060bd84f0, geometry=0,0 50x50) after QQuickRectangle(0x1b060bdb110), which must be a sibling QQuickItem::stackAfter: Cannot stack QQuickRectangle(0x1b060bdb030, parent=0x1b060bd84f0, geometry=0,0 50x50) after QQuickRectangle(0x1b060bdbab0), which must be a sibling
Note that the delegate has `DelegateModel.inPersistedItems: false` and the list view has `reuseItems: false` but none of those seem to help get the expected result.
Edit: After fiddling around I found out a couple of relevant things:
1 - forceLayout() doesn't help in case the delegates are stuck in diagonal or incorrect configuration
2 - setting the model of the outgoing view to null before creating the new one appears to result in expected output, even without the use of inPersistedItems or reuseItems
2 points out to some kind of exclusive relation being established between the DelegateModel and the view that uses it. Is this correct behavior or a bug? I'd expect that I can use the same DelegateModel to source any number of views, or as in this case - simply substitute one view with another.