Selecting item in QML TreeView does not change isSelected of item
Solved
QML and Qt Quick
-
I have created a simple TreeView in QML, with several levels of nesting. I have also created an "itemDelegate" and a "rowDelegate"; both of which switch background color between red/black bound to their respective isSelected.
When I click on an item the ROW color changes, but the item does not. I confirmed the itemFlag for each item includes ItemsIsSelectable and ItemIsEnabled (default).
My itemDelegate contains:
Rectangle { color: styleData.isSelected ? "red" : "black"
I added a selection to the treeview:
ItemSelectionModel { id: treeViewSelectionModel objectName: "treeViewSelectionModel" model: treemodel onCurrentChanged:{console.log("Selection - current changed from ",previous, " to ", current)} }
Which correctly prints out the new/previous selection. So it appears the item is being selected, but not changing color (the isSelected never changes for the item). Can someone explain why?