9

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.

Community
  • 1
  • 1
Ionică Bizău
  • 109,027
  • 88
  • 289
  • 474

2 Answers2

11

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

TheDarkKnight
  • 27,181
  • 6
  • 55
  • 85
3

Try this :

QCursor::pos()

should work perfectly

Thomas Ayoub
  • 29,063
  • 15
  • 95
  • 142