Details
-
Bug
-
Resolution: Done
-
P3: Somewhat important
-
4.8.5, 5.1.1
-
None
-
Mac OS X 10.6
-
290dc6caf65aeecaceb5a67b55cb33f0b059f98a
Description
when explicitly setting a view's model to an empty array (or an empty
ListModel, C++-Model, etc.) the currentIndex property changes from -1
to 0. Initializing the model property with an empty model works as
expected.
import QtQuick 2.0 Rectangle { width: 360 height: 360 ListView { id: view anchors.fill: parent // model: [] // this works, currentIndex will be -1 delegate: Text { text: modelData } } Text { anchors { right: parent.right } text: view.currentIndex MouseArea { anchors.fill: parent onClicked: view.model = [] // now currentIndex becomes 0 } } }
This looks like a bug to me because 0 is obviously not a valid index for an
empty model. It's the same behavior in QtQuick 1 and QtQuick 2.
The same problem occurs when assigning an empty Qml ListModel.
Attachments
For Gerrit Dashboard: QTBUG-32838 | ||||||
---|---|---|---|---|---|---|
# | Subject | Branch | Project | Status | CR | V |
62349,4 | Fix currentIndex in Qml itemView when assigning an empty model | stable | qt/qtdeclarative | Status: MERGED | +2 | 0 |