Results 1 to 3 of 3

Thread: Double Click Capturing

  1. #1
    Join Date
    Jan 2006
    Location
    Ohio
    Posts
    332
    Thanks
    37
    Thanked 8 Times in 4 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Question Double Click Capturing

    I have some code that captures mousePressEvents, mouseReleaseEvents, mouseMoveEvents, and mouseDoubleClickEvents for a QGLWidget. I have it do many things based on which of the events occur. Inside my mouseReleaseEvent I have some code that is to only be executed if a double click did not occur. But when I would double click I noticed I was entering the release code.

    I set up some break points and noticed on a double click the order of events is:

    1. mousePressEvent
    2. mouseReleaseEvent
    3. mouseDoubleClickEvent
    4. mouseReleaseEvent

    Is there a way to tell if there is a double click event in the queue of mouse events because I would prefer to enter the double click event code first and then check the release event code and completely ignore the press event code if I double click. I am using Qt 3.3.7. Thanks for your help!

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Double Click Capturing

    You could have a timer. Start the timer in the releaseEvent handler and make sure the timeout is long enough to handle the double click first. Then, in the double click event handler you can stop the timer and prevent it from firing. If a double click handler is not triggered, the timer will timeout and call a slot of your choice, where you can handle the single click. This is of course a nasty hack, but has a chance to work.

  3. #3
    Join Date
    May 2009
    Posts
    133
    Thanks
    10
    Thanked 4 Times in 3 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Double Click Capturing

    You might want to take a look at Raymond Chen's blog post titled Logical consequences of the way Windows converts single-clicks into double-clicks where he describes the same technique Wysota does but makes some additional remarks on why it's a bad idea.

Similar Threads

  1. Replies: 1
    Last Post: 9th February 2007, 10:41
  2. QGraphicsScene Click / Double Click
    By philentropist in forum Qt Programming
    Replies: 1
    Last Post: 9th February 2007, 05:32
  3. QTreeWidget double click signal
    By Pinco Pallino in forum Newbie
    Replies: 2
    Last Post: 18th November 2006, 17:37
  4. Push button double click
    By curtisw in forum Qt Programming
    Replies: 3
    Last Post: 15th February 2006, 17:40
  5. Replies: 5
    Last Post: 12th January 2006, 16:40

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.