Can I make a QML Item contained into a ListView object unselectable? Something like this
for(var i=0; i < ListView.model.count; i++) {
ListView.model.get(i).selectable = false; 开发者_StackOverflow社区
}
If by "unselectable" you mean to prevent the user from being able to click on the item then you can add a selectable
property to the model as you have done, then use it in the onClicked
event in your ListView
delegate - something like this:
ListView {
...
delegate: Item {
....
MouseArea {
anchors.fill: parent;
onClicked: {
if(selectable) {
//Do Something Interesting...
}
}
}
}
Also, it looks like you are referencing the model incorrectly. Either use the id of the ListView
(e.g. myListView.model
) or if your for loop is within scope you can refer to the model
directly.
精彩评论