Mouse movement

I am writing a little for me in ruby ​​using qt. How do I access global mouse movements and keyboard input events?

0


a source to share


3 answers


If you need to track your mouse movement when no buttons are pressed, you want to enable mouse tracking on the widgets that you want to track the mouse on. A function QWidget::setMouseTracking()

available for all QWidget

s will allow you to do this.

To capture mouse movements, you will need to capture QMouseMoveEvent

s. There are two ways to do this:



For the official Qt documentation, click on the links to the functions of interest.

+3


a source


Use QWidget :: grabMouse () and note that this is a very dangerous function, use it with caution.



+2


a source


For the mouse position, have you tried QCursor :: pos () ?

0


a source







All Articles