Details
-
Bug
-
Resolution: Unresolved
-
P2: Important
-
None
-
6.5.3, 6.6.1
Description
The document of QWidnow::setGeometry said the coordinate system is realted to QScreen::virtualGeometry, however, it appears wrong if any screen has devive pixel ratio greater than 1.
It seems QScreen::geometry and QScreen::virtualGeometry all return QRect in device independent pixel (that is, divided by devicePixelRatio), but QWindow::setGeometry expect QRect in pixels.
If you try to set window to fullfill all screens (and screens have devicePixelRatio > 1)
widnow->setGeometry(screen->virtualGeometry());
You will notice it will not cover all screens, but if I do the calculation to convert virtualGeometry to pixel, it works fine.
static QRectF patchedVirtualGeometry(QWidnow* widnow) { QRectF rect; for (auto sibling : window->screen()->virtualSiblings()) { auto box = sibling->geometry(); box.setTopLeft(box.topLeft() * sibling->devicePixelRatio()); box.setSize(box.size() * sibling->devicePixelRatio()); rect |= box; } return rect; } // doc say so, but does not work window->setGeometry(widnow->screen()->virtualGeometry()); // have to use this window->setGeometry(patchedVirtualGeometry(window));