Can't add to ItemSelectionModel list of selected model indexes
Unsolved
QML and Qt Quick
-
I have a simple QQC2 TreeView and when I click an item in my tree I want to add it to my ItemSelectionModel. Based on docs and examples online I have created the code below. And when clicking an item in my tree it correctly highlights as current, and the onCurrentModelIndexChanged handler fires.
When the handler fires the hasSelection shows true, and the current model index printed is correct. However, the selectedIndex list is always empty. Why is the list not being populated?
Rectangle { id: paneMenu anchors.fill: parent color: gui.colorRGBString(GUIConstants.EColorElement_Background) TreeView { id: mytreeview anchors.fill: parent model: treemodel delegate: delegateMenuItem onCurrentModelIndexChanged: { selModel.select(currentModelIndex, ItemSelectionModel.Select | ItemSelectionModel.Current) console.log("**selModel has selection: "+selModel.hasSelection) console.log("**Selected indexes:"+selModel.selectedIndexes) console.log("**Current model index:"+currentModelIndex) } } }