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
You can override QWidget::mouseMoveEvent()
and update your window position there.
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.
精彩评论