I have a QTreeView with parents/children and want to do the following:
1. Only allow the parent of an item to be selected
2. Have the children be unselectable, but allow their checkboxes to be toggled
However -- clicking on a child item does the following two (bad) things:
1. It removes the selection from the parent
2. It leaves some "highlight" mark behind on the child.
Note that I've made the children "unselectable" via model flags, but the two issues above still occur. How can I prevent both of these things from happening?
----------
DESIRED BEHAVIOR
If the user clicks on a child, I want to keep the selection on the Parent uninterrupted (without manually flipping it back to the parent, which causes a "flicker"). And, I don't want the child to get "highlighted" by the translucent selection thing.
Pictures to illustrate:
Normal state. Parent is selected. Children have checkboxes.
treeview1.PNG
Bad behavior. Clicking on 2nd child (that's flagged as unselectable) causes the Parent to lose its selection, and gives the child the ghost selection
treeview2.PNG
Desired. This is what I want to see when I click on a child item -- the checkbox toggles, and the Parent remains selected without interruption.
treeview3.PNG
This must be possible, but I can't find the right combination of settings to get the selections to work as in the 3rd picture.
Any help would be greatly appreciated.
Bookmarks