Details
-
Bug
-
Resolution: Unresolved
-
P2: Important
-
None
-
5.15.2
-
None
Description
QML applications (couldn't test on QWidget) on High-DPI multi-monitor setups cannot use `QCursor::setPos` reliably.
How to reproduce:
- Use a setup with at least 2 monitors with DPI scaling enabled (200% on each screen is what I used).
- Start the application. It will open on your primary monitor
- Move the application's window to the other (secondary) monitor
- Call `QCursor::setPos(x, y)`. The X coordinate will always reset to 0.
Here is a very short code snippet of the issue:
const auto offset = ...; // Some code that computes an offset const auto currentPos = cursor->pos(); const auto newPos = currentPos + offset; cursor->setPos(newPos);
When I run the code snippet from a window on my primary monitor I get the following log:
- `currentPos = QPoint(4419, 111)`
- `newPos = QPoint(5750, 111)`
- After calling setPos, `cursor->pos() = QPoint(5750, 111)` (equal to what was expected)
If I run this exact same code but I move my application's window to my secondary monitor, I get the following log:
- `currentPos = QPoint(582, 70)`
- `newPos = QPoint(1913, 70)`
- After calling setPos, `cursor->pos() = QPoint(0, 70)` (X coord has been reset to 0)
Configs on which I could repeat the issue:
Arch Linux
DE: Gnome 41
X server: Xorg
Qt version: 5.15.2
Primary display: 4K @200% scaling
Secondary display: 4K @200% scaling
Ubuntu 21.04
DE: Gnome 3.38.5
X Server: Xorg
Qt version: 5.15.2
Primary display: 1440p @200% scaling
Secondary display: 1440p @200% scaling
Windows 10
Qt version: 5.15.2
Primary display: 1920×1080 @150% scaling
Secondary display: 4K @200% scaling
I have a small project available that shows the example but Jira tells me there is a "missing token" when I try to upload it, I don't know how I can attach it to this message.
In the meantime the files content can be found in the last message of this ticket on Qt's forum: https://forum.qt.io/topic/132330/qcursor-setpos-sets-wrong-x-coordinates/7
Attachments
Issue Links
- duplicates
-
QTBUG-78320 [HighDPI multi-monitor Mixed screen scale factors] QCursor::setPos setting incorrect positions on non-primary monitor
- Reported
- relates to
-
QTBUG-55038 QCursor::setPos(const QPoint &p) fails when the point is not on the primary screen.
- Open