Michael
Michael

Reputation: 61

Qt - Find mouse screen x,y - even application closed

I'm new to Qt. I'd like a window to follow the mouse around the screen. (It's a useful aid to reading)

The best I can come up with is a timer that uses QPoint QCursor::pos() to move the window every .1 seconds.

Rather than spinning this timer constantly, is there an event system I can tap into? This would look smoother, and use less computer.

Is there a better way?

Thanks,

Mike

Upvotes: 0

Views: 356

Answers (2)

György Andrasek
György Andrasek

Reputation: 8277

Try QTimer and its timeout() signal. The event system you're looking for is probably the main event loop, provided by the QCoreApplication or the QApplication classes.

Upvotes: 0

Georg Fritzsche
Georg Fritzsche

Reputation: 99064

You can override QWidget::mouseMoveEvent() and update your window position there.

Upvotes: 2

Related Questions