[Interest] Qml ListView currentIndex behavior
Nils Jeisecke
njeisecke at saltation.de
Mon Aug 5 18:58:29 CEST 2013
Hi list,
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 not a valid index for an
empty model. It's the same behavior in QtQuick 1 and QtQuick 2.
Any ideas?
Nils
More information about the Interest
mailing list