Results 1 to 3 of 3

Thread: Differentiating single-clicks and double-clicks in a QTreeWidget

  1. #1
    Join Date
    Dec 2010
    Posts
    10
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Windows

    Default Differentiating single-clicks and double-clicks in a QTreeWidget

    I would like to have different program behavior when a user single-clicks or double-clicks an item in a QTreeWidget. As it happens, when I double-click an item two signals are emitted: itemClicked and itemDoubleClicked. Is there a way around this?

    Thanks,
    Adam

  2. #2
    Join Date
    Jan 2006
    Location
    Germany
    Posts
    4,380
    Thanks
    19
    Thanked 1,005 Times in 913 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60
    Wiki edits
    5

    Default Re: Differentiating single-clicks and double-clicks in a QTreeWidget

    You have to reimp QTreeView::mousePressEvent() and QTreeView::mouseDoubleClickEvent() yourself and emit e.g custom signals.

  3. The following user says thank you to Lykurg for this useful post:

    adamb924 (22nd December 2010)

  4. #3
    Join Date
    May 2010
    Location
    Romania
    Posts
    1,021
    Thanks
    62
    Thanked 260 Times in 246 Posts
    Qt products
    Qt5
    Platforms
    MacOS X Unix/X11 Windows Android

    Default Re: Differentiating single-clicks and double-clicks in a QTreeWidget

    QTreeWidget already has signals:
    Qt Code:
    1. void itemClicked ( QTreeWidgetItem * item, int column )
    2. void itemDoubleClicked ( QTreeWidgetItem * item, int column )
    To copy to clipboard, switch view to plain text mode 
    See all it's signals here

Similar Threads

  1. Replies: 3
    Last Post: 12th May 2010, 13:11
  2. QTabWidget: Shortcuts & Clicks
    By youkai in forum Qt Programming
    Replies: 7
    Last Post: 20th July 2009, 14:12
  3. Generating Mouse Clicks
    By Ebonair in forum Qt Programming
    Replies: 2
    Last Post: 4th July 2009, 18:20
  4. How to handle double clicks with mouse?
    By Morea in forum Qt Programming
    Replies: 1
    Last Post: 14th January 2007, 12:01
  5. QTreeWidget, double-clicks and assertion errors
    By Byngl in forum Qt Programming
    Replies: 1
    Last Post: 13th September 2006, 14:29

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.