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!
Re: how to avoid mousePressEvent in case of mouseDoubleClickEvent
Re: how to avoid mousePressEvent in case of mouseDoubleClickEvent
Quote:
Originally Posted by
Naami
Hi;
What do you mean;
I mean, idealy I do not want mousePressEvent was called in case if mouseDoubleClickEvent is about to be called
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)
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!
Re: how to avoid mousePressEvent in case of mouseDoubleClickEvent
Re: how to avoid mousePressEvent in case of mouseDoubleClickEvent
Quote:
Originally Posted by
medved6
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...