HighDPI support and scaling
-
Hello,
To handle multiple monitors with different resolutions, I setting the following setting as per documentation:QApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
I have 4K laptop screen, and a 4K external monitor. Both of them are running at the same resolution. I think the PPI is different for the two monitors.
With the HighDpiScaling enabled, when I move my application from the external monitor to the laptop screen, all the fonts (in the dock widgets, menu bar, etc.) appear much bigger.
Conversely, when I move the application launched on the laptop screen first, to the external monitor the fonts are too small. All the controls like status bar, menu bar, slider thickness, etc. also vary similarly.
I have the exact same problem with QtCreator also. What am I doing wrong? How do I solve this problem?
Laptop Screen:
External Monitor:
Thanks.
-
Hi
For your app, step one would be to hook up to
https://doc.qt.io/qt-5/qwindow.html#screenChanged
and check devicePixelRatio() if it does indeed change. -
-
@JohnGa
Hi
Looking at the docs
https://doc.qt.io/qt-5/highdpi.html#migration-of-existing-applications
It seems you can set scaling pr screen.
"The format can be either a semicolon-separated list of scale factors in the same order as QGuiApplication::screens(), or a semicolon-separated list of name=value pairs, where name is the same as QScreen::name()."so if you inspected QScreen::name() you could have a scaling pr screen. via QT_SCREEN_SCALE_FACTORS
Im not sure that the best or the only way.
Maybe others have easier/better solution.