Results 1 to 3 of 3

Thread: Shift Click on (+) in QTreeView

  1. #1
    Join Date
    Sep 2015
    Posts
    3
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Shift Click on (+) in QTreeView

    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.

  2. #2
    Join Date
    Jun 2015
    Location
    India
    Posts
    185
    Thanks
    8
    Thanked 14 Times in 14 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Shift Click on (+) in QTreeView

    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...
    Last edited by prasad_N; 2nd September 2015 at 18:42.
    Thanks :-)

  3. #3
    Join Date
    Sep 2015
    Posts
    3
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Shift Click on (+) in QTreeView

    Hi.
    That solution does seem to work for me. At least for now. Thanks for your help!

    Jatin.

Similar Threads

  1. QTreeView: shift-click [+] decorator to fully expand branch
    By chezifresh in forum Qt Programming
    Replies: 1
    Last Post: 2nd September 2015, 12:47
  2. Replies: 2
    Last Post: 19th May 2014, 19:25
  3. Move rows of Qtreeview up and down on button click
    By GAURAV PANT in forum Qt Programming
    Replies: 1
    Last Post: 23rd April 2014, 14:14
  4. Replies: 3
    Last Post: 1st April 2011, 05:58
  5. QPushButton on Shift+Click?
    By vishal.chauhan in forum Qt Programming
    Replies: 3
    Last Post: 9th September 2008, 11:00

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.