QCursor::setPos doesn't support float arguments?
-
Hello!
Noticed thatQCursor::setPosonly acceptintcoordinates, so I can't perfectly set the mouse pos under high DPI screens?I'm trying to make a drag zone on QML that prevents the mouse to go outside the window while dragging:
- start dragging, record start coordinate
- onPositionChanged, calculate mouse coord delta, emit event
QCursor:::setPosmove mouse back to start coord- onPositionChanged...
- In the end the user is able to move something (like a slider, based on emitted delta events)
while preventing the mouse to go outside the window
On 100% scaled screens it works fine, but on 125% scaled screen the moved "thing" starts drifting, e.g. if you move the mouse in a circle the "thing" starts to drift to the corner of the window.
My guess is QCursor::setPos accepts
intarguments so each time it's not perfectly set to the start coordinate, causing a bias to the delta events.Platform is Windows.
Thanks!
-
This post is deleted!
-
Example codes:
- QML drag zone: https://pastebin.com/WjEGTBiV
- QML main: https://pastebin.com/0eZJqFVh
- C++ helper: https://pastebin.com/1L66xgTh
-
There might be a rounding error somewhere but you can't position on a half pixel in e.g. windows - see SetCursorPos.
So yes, with 125% the logical position 61/62 is mapped to the physical position 76/78 while it should be 76,25/77,5 but SetCursorPos can't handle this.