PDA

View Full Version : how to avoid mousePressEvent in case of mouseDoubleClickEvent



medved6
16th June 2010, 08:51
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!

Naami
16th June 2010, 19:58
Hi;
What do you mean;

medved6
16th June 2010, 23:45
Hi;
What do you mean;

I mean, idealy I do not want mousePressEvent was called in case if mouseDoubleClickEvent is about to be called

wysota
17th June 2010, 00:04
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)

medved6
17th June 2010, 05:53
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!

aamer4yu
17th June 2010, 07:12
Will QApplication::doubleClickInterval be of any use to you ?

wysota
17th June 2010, 09:41
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...