[SOLVED] Mouse Tracking With GUI Builder
Hi, My goal is to create a simple test application where a dial will be moved by the movement of a mouse.
This is to say ONLY the movement of the mouse. I was trying something like
@MainWindow::MainWindow(QWidget *parent) :
@void MainWindow::mouseMoveEvent(QMouseEvent* )
However it didn't seem to work. It only worked when the mouse was pressed which was not my goal.
Thank you for your help
You can use an event filter on the application.
Define and implement bool MainWindow::eventFilter(QObject*, QEvent*). For example..
@bool MainWindow::eventFilter(QObject *obj, QEvent *event)
if (event->type() == QEvent::MouseMove)
QMouseEvent mouseEvent = static_cast<QMouseEvent>(event);
statusBar()->showMessage(QString("Mouse move (%1,%2)").arg(mouseEvent->pos().x()).arg(mouseEvent->pos().y()));
Install the event filter when the MainWindows is constructed (or somewhere else). For example..
Thanks! that worked great.
please mark ur thread as solved...
Can you please post your complete code of mouse movements because my requirement is similar one i.e to display co-ordinates on world map with movement of mouse on map.
Can you help me in my requirement of displaying world map and co-ordinates on map with mouse movements