Customize selection behavior for QTreeView

545 views Asked by At

I have QTreeView and I want multi selection behavior in case if node is leaf, otherwise single selection behavior, so do not allow to select non-leaf node if some node already selected, and do not allow to select any other node if non-leaf node is selected. How to implement that?

1

There are 1 answers

0
Michał Walenciak On

You may try to control selection behavior by deriving from QTreeView and overloading selectionCommand.

Using this method you can check what item was clicked (node/leaf) and then return proper SelectionFlags.