Unsolved Get mouse cursor position in pixels
-
I was just debugging a weird problem when I realized mouse coordinates are now returned in some abstract points, not physical pixels. Possibly due to changes in high DPI support (this is on Mac with retina display).
I've got an OpenGL widget and I need coordinates in pixels in order for everything to work. As it is now, Qt seems to be dividing pixel coordinates by 2 (window height is 1600 and the cursor position only goes up to 800).How can I get the cursor position in pixels from mouse events?
-
@Violet-Giraffe said in Get mouse cursor position in pixels:
I was just debugging a weird problem when I realized mouse coordinates are now returned in some abstract points, not physical pixels. Possibly due to changes in high DPI support (this is on Mac with retina display).
I've got an OpenGL widget and I need coordinates in pixels in order for everything to work. As it is now, Qt seems to be dividing pixel coordinates by 2 (window height is 1600 and the cursor position only goes up to 800).How can I get the cursor position in pixels from mouse events?
How are you getting the mouse pos
Have you tried qcursor::pos ?
-
@mostefa said in Get mouse cursor position in pixels:
How are you getting the mouse pos
mouseEvent->pos()
.QCursor::pos()
is not a substitute for that, for obvious reasons. -
Bump. This is a very serious issue. There must be some way to convert the mouse coordinates into system units!
-
-
@SGaist said in Get mouse cursor position in pixels:
By the way, what version of Qt are you using ?
Hi, thank you, on-point answer as always. That works, but it raises a question: if there are multiple monitors, how do I know which QScreen to use?
P. S. Think I've found a way:QApplication::desktop()->screenNumber(widget)
obtains the screen number which can be used to get the screen fromQApplication::screens()
.I'm using Qt 5.8 on Mac.