PDA

View Full Version : Shift Click on (+) in QTreeView



Jatin Parekh
2nd September 2015, 12:44
In a QTreeView, a node with child nodes has the ( + ) icon on the left of it.
How can I detect in MousePressEvent if the click was made on the ( + ) icon or not?

All my previous attempts have only helped me in getting the current selected Index. I am unable to gain access to the dimesnsions/position of the +/- icon to work with.
If it helps, I am trying to add a Shift + Click functionality where a node and all its children would be recursively expanded till leaf ONLY if the Shift+Click is made on the +/- sign in the tree view.

prasad_N
2nd September 2015, 13:14
there is a signal expanded(const QModelIndex & index ) in QTreeView, You can use this.

Have a flag set in keypress event & reset it in key release event (in customize qtreeview) if you press shift And then in the slot connected to exapnded you can check the flag for shift press & you have modelIndex of the item also...

Jatin Parekh
3rd September 2015, 06:22
Hi.
That solution does seem to work for me. At least for now. Thanks for your help!

Jatin.