How to get the mouse position on the screen in Qt?

不羁的心 提交于 2019-12-08 17:41:46

问题


I want to get the mouse coordinates on the screen.

How can I do this in Qt?


On Windows, using C# I was doing something like suggested in the answers to this question.


回答1:


As the docs state: -

QCursor::pos()

Returns the position of the cursor (hot spot) of the primary screen in global screen coordinates.

If you have multiple screens, you can use: -

QPoint QCursor::pos(const QScreen * screen) 

Note that QScreen is for Qt 5




回答2:


Try this :

QCursor::pos()

should work perfectly



来源:https://stackoverflow.com/questions/19523375/how-to-get-the-mouse-position-on-the-screen-in-qt

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!