Details
-
Bug
-
Resolution: Unresolved
-
P2: Important
-
None
-
6.5.1
-
None
Description
The example code below creates a 32-logical-pixels-tall window and sets a custom 2x-scaled cursor. The cursor size should match the window height exactly, and the hotspot should lay at the center of the cursor.
#include <QWindow> #include <QGuiApplication>int main(int ac, char *av[]) { QGuiApplication app(ac,av); QWindow w; QImage image(64, 64, QImage::Format_ARGB32); image.fill(0); auto pixels = (uint32_t*)image.bits(); for(int i=0;i<64;i++) { pixels[i*64+i] = 0xffff0000; pixels[i*64+63-i] = 0xff0000ff; } auto pixmap = QPixmap::fromImage(image); pixmap.setDevicePixelRatio(2); w.setCursor(QCursor(pixmap, 16, 16)); w.resize(200, 32); w.show(); app.exec(); return 0; }
This works correctly on Windows and Mac. On X11 however, two issues are apparent:
- The pixmap's devicePixelRatio is ignored and the cursor is 64x64 even on low-dpi displays. This also causes the hotspot position to be applied incorrectly
- The display scaling factor is ignored and the cursor size doesn't match the window size on high-dpi displays (except for exact 2x scaling where the two issues cancel out).