PDA

View Full Version : How to know mouse release event in mouse move event



ankireddy
6th January 2012, 12:33
Hello,

I want to collect all the mouse points along the mouse when I drag the mouse(left button press and move). So I wrote "mouseMoveEvent" in a Widget and getting the x, y coordinates.

If I move the mouse very slowly then only I am getting all points along the mouse.

If I move a little bit fast then I am not able to collect all the points along the mouse. It is missing some points along the path. And if the mouse move speed is over then missing many points.

So I am planing to put a while loop in "mouseMoveEvent" and then get mouse co ordinates with "Cursor::pos()". Now I want to break while loop when I release mouse button.

How to know in "mouseMoveEvent" thet I release mouse button?

Is there any alternative method to do this other than putting while in "mouseMoveEvent" ?

Can you please help me what to do?

Thanks & Regards
anki

wysota
6th January 2012, 15:03
You are getting all the points. The operating system reports mouse moves with some granularity, otherwise it would be overwhelmed with events. Any while loop inside mouseMoveEvent is bound to block your application and you will not get any events because you will block when receiving the first one before the next one is sent to your app. If you want better precision then you just have to mouse your mouse slowly or somehow configure your operating system to generate more events although it will significantly slow down your system and worsen your user experience.

ankireddy
7th January 2012, 03:52
No, I am not getting all points. I am drawing all co-ordinates which are getting in mouseMove to screen by update() (calling paintEvent). It is setting only few points.

Is there any call to get event like postEvent.

Or is there any way to get event object from the QObject event system.

Thanks and regards
anki

Lykurg
7th January 2012, 08:38
You are getting all events, there are simply not more emitted. You could write your own methods with a timer querying QPointer::pos() and start them via mousePress and mouseReleaseEvent. But that - as said - slows your system down...