Results 1 to 7 of 7

Thread: how to avoid mousePressEvent in case of mouseDoubleClickEvent

  1. #1
    Join Date
    Dec 2009
    Posts
    50
    Thanks
    9
    Qt products
    Qt4
    Platforms
    Windows

    Default how to avoid mousePressEvent in case of mouseDoubleClickEvent

    Hi Everybody.

    I have my own subclass of QGraphicsView.


    If I get mousePressEvent/mouseReleaseEvent a lot of actions takes place. But what if I do not want to do that actions in case of mousePressEvent/mouseReleaseEvent is just a part of mouseDoubleClickEvent.

    Is there any eligant way to do that?

    Thank you in advance!

  2. #2
    Join Date
    May 2010
    Location
    Algeria
    Posts
    23
    Thanks
    5
    Thanked 1 Time in 1 Post
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: how to avoid mousePressEvent in case of mouseDoubleClickEvent

    Hi;
    What do you mean;

  3. #3
    Join Date
    Dec 2009
    Posts
    50
    Thanks
    9
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: how to avoid mousePressEvent in case of mouseDoubleClickEvent

    Quote Originally Posted by Naami View Post
    Hi;
    What do you mean;
    I mean, idealy I do not want mousePressEvent was called in case if mouseDoubleClickEvent is about to be called

  4. #4
    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: how to avoid mousePressEvent in case of mouseDoubleClickEvent

    You can't avoid it because there is no way of knowing whether a second click will come after the first one so the first one has to initiate a mouse press event. What you can do is to cheat by starting a timer in mouse press event with a small timeout. If double click event comes then stop the timer and ignore it. Otherwise when the timer fires, you will know that there was no double click and you can handle the event as usual.

    The downsides of such solution are:
    • handling of all mouse clicks will be delayed which might be annoying to the user
    • you will be handling mouse release events before mouse press events which might be annoying to the programmer
    • you won't get event propagation
    • double mouse click delay can be set differently on different systems so you never know what timeout to use (which might simply make this solution incorrect)
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  5. #5
    Join Date
    Dec 2009
    Posts
    50
    Thanks
    9
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: how to avoid mousePressEvent in case of mouseDoubleClickEvent

    I understand all that. And how to avoid all this( manual timers) was exactly my question.
    On windows as far as I know microsoft does all you said already( win api takes in account pre-setuped double click delay ).
    I was thinking if it's possible to have something simular in QT for "free".
    Thank you!

  6. #6
    Join Date
    Oct 2006
    Location
    New Delhi, India
    Posts
    2,467
    Thanks
    8
    Thanked 334 Times in 317 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: how to avoid mousePressEvent in case of mouseDoubleClickEvent

    Will QApplication::doubleClickInterval be of any use to you ?

  7. The following user says thank you to aamer4yu for this useful post:

    medved6 (18th June 2010)

  8. #7
    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: how to avoid mousePressEvent in case of mouseDoubleClickEvent

    Quote Originally Posted by medved6 View Post
    On windows as far as I know microsoft does all you said already( win api takes in account pre-setuped double click delay ).
    You mean that if I set a 10s delay for the double click on my system, I will get each mouse press event in WinAPI after 10 seconds? That would really be strange...
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


Similar Threads

  1. MouseDoubleClickEvent on a QGraphicsScene
    By paolom in forum Qt Programming
    Replies: 6
    Last Post: 6th October 2009, 11:01
  2. mouseDoubleClickEvent on QGraphicsItem's
    By been_1990 in forum Qt Programming
    Replies: 11
    Last Post: 7th August 2009, 02:52
  3. mouseDoubleClickEvent in QGraphicsItemGroup
    By dima in forum Qt Programming
    Replies: 0
    Last Post: 9th March 2009, 07:01
  4. Problem of mouseDoubleClickEvent
    By Sarma in forum Qt Programming
    Replies: 18
    Last Post: 8th March 2006, 06:31

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.