Mouse movement
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:
- If you are defining your own widget, then override
QWidget::mouseMoveEvent()
. - If you are using a stock widget, you can create an event filter class and set an event filter on the widget that you want to track with your mouse movements. See
QObject::installEventFilter()
.
For the official Qt documentation, click on the links to the functions of interest.
+3
a source to share