Results 1 to 2 of 2

Thread: QTreeWidget disable ctrl to deselect

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    May 2013
    Posts
    321
    Thanks
    9
    Thanked 8 Times in 8 Posts
    Qt products
    Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default QTreeWidget disable ctrl to deselect

    Hi,
    Is it possible to disable the deselect action using ctrl + left click on an item of a QTreeWidget ?
    How achieve that correctly ?
    Thanks

  2. #2
    Join Date
    May 2013
    Posts
    321
    Thanks
    9
    Thanked 8 Times in 8 Posts
    Qt products
    Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: QTreeWidget disable ctrl to deselect

    Answer :
    Qt Code:
    1. virtual void mousePressEvent( QMouseEvent* event )
    2. {
    3. QTreeWidgetItem* Item = itemAt( event->pos() );
    4. if( Item && Item != currentItem() )
    5. {
    6. clearSelection();
    7. Item->setSelected( true );
    8. }
    9. event->accept();
    10. }
    To copy to clipboard, switch view to plain text mode 

Similar Threads

  1. Replies: 2
    Last Post: 10th December 2015, 09:59
  2. Replies: 0
    Last Post: 5th September 2015, 00:22
  3. How to disable CTRL+V on a QLineWidget
    By sanket.mehta in forum Qt Programming
    Replies: 4
    Last Post: 3rd December 2010, 10:31
  4. disable ALT+CTRL+DEL!!!!
    By phillip_Qt in forum Qt Programming
    Replies: 10
    Last Post: 3rd November 2009, 09:23
  5. Replies: 1
    Last Post: 8th March 2007, 10:12

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
  •  
Qt is a trademark of The Qt Company.