Details
-
Bug
-
Resolution: Out of scope
-
P2: Important
-
None
-
5.15.16, 6.9.0
-
None
-
- Qt Version: [5.15.16]
- OS: Manjaro Linux, Wayland and other distros supporting wayland
Description
What did you do?
I want to get devicePixelRatio with QScreen in Wayland of Manjaro. However, it always returns an integer value, even though I am running using a fractional scaling ratio.
This is my display setup
This is my Qt code
I use code below to query the devicePiexlRatio using Qt5.
#include <QApplication> #include <QScreen> #include <QDebug> int main(int argc, char *argv[]) { QApplication app(argc, argv); // Get the primary screen QScreen *screen = QApplication::primaryScreen(); if (!screen) { qDebug() << "Error: No primary screen detected."; return 1; } // Query and print devicePixelRatio qreal pixelRatio = screen->devicePixelRatio(); qDebug() << "Device Pixel Ratio:" << pixelRatio; qDebug() << "Screen Name:" << screen->name(); qDebug() << "Physical DPI:" << screen->physicalDotsPerInch(); qDebug() << "Logical DPI:" << screen->logicalDotsPerInch(); return app.exec(); }
I tested it with high dpi env var enabled or disabled, neither worked.
The result is
$./test_pixelratio
Device Pixel Ratio: 2
Screen Name: "eDP-1"
Physical DPI: 126.192
Logical DPI: 96
What did you expect to happen?
An accurate devicePixelRatio, in my case, should be 1.25.
What happened instead?
An integer value. It returns 2.
What I am suspecting
You didn't support fractional scaling ratio in QtWaylandScreen. I read the code, though it is qt6.
It had implemented fractional_scale_v1, the wayland protocol that supports the fractional scaling ratio. And it had a fractional scaling manager. But it is only integrated into the qt wayland related window class, not QtWaylandScreen.
I might also miss some other widgets or components that still fully supports fractional scaling ratio.
Attachments
For Gerrit Dashboard: QTBUG-135612 | ||||||
---|---|---|---|---|---|---|
# | Subject | Branch | Project | Status | CR | V |
638066,2 | Discourage use of QScreen::devicePixelRatio() | dev | qt/qtbase | Status: NEW | +2 | 0 |