High DPI scaling detection
-
Hi all,
I would like to detect the scaling rate of the current display. I checked several values but couldn't find anything helpful:
DisplayZoom pixelRatio physicalDPI logicalDPI screenSize fontSize 100% 1 108.888 96 2560x1400 8 125% 1 108.888 120 2560x1390 8 150% 2 54.4438 96 1280x 690 8 175% 2 54.4438 96 1280x 685 8 200% 2 54.4438 96 1280x 680 8
Unlike the menu bar that's scaling correctly several elements like the status bar and text's in the tab widget tend to break out being too big or to small on several systems (Windows, Mac, Linux).
I read the chapter about High DPI Displays but there's nothing I didn't already tried out.
Best regards
Jazzco -
Update:
The font size of the
QMenu
and theQTabBar
do not differ in the main windows constructor. But after waiting for the followup events to be processed these fonts differ in fact.To get the
QTabBar
having the same font size as theQMenu
it doesn't help to just assign the menus font to the it. It is necessary to explicitly assign the pointSize to the font before assigning it to the destination widget (here theQTabBar
).Additionally one can get the
QFontMetrics::height()
for concrete values.I mark this solved.
Best
Jazzco -
Hi,
You should add which Qt version as well.
-
Ah right, it's Qt 5.15.2 - and several versions before that. We won't change to current Qt 6 until the WebEngine is part of it.
-
@Pl45m4 said in High DPI scaling detection:
As I told, I already worked through that page. The problems still exist. Therefore the question if there is any value in the libraries of Qt telling what scaling is active on the current display.
-
@Pl45m4 said in High DPI scaling detection:
As I told, I already worked through that page. The problems still exist. Therefore the question if there is any value in the libraries of Qt telling what scaling is active on the current display.
@jazzco2 said in High DPI scaling detection:
As I told, I already worked through that page. The problems still exist
So you must have missed something :)
Device Pixel Ratio The scale factor that either the operating system or Qt applies.
This is obtainable from every
QWindow
as well as fromQScreen
Edit:
Isn't the pixelRatio already listed in your table? Or am I missing something now? Or I am not getting what you mean?!
From documentation:
Common values are 1.0 on normal displays and 2.0 on "retina" displays. Higher values are also possible.
-
@jazzco2 said in High DPI scaling detection:
As I told, I already worked through that page. The problems still exist
So you must have missed something :)
Device Pixel Ratio The scale factor that either the operating system or Qt applies.
This is obtainable from every
QWindow
as well as fromQScreen
Edit:
Isn't the pixelRatio already listed in your table? Or am I missing something now? Or I am not getting what you mean?!
From documentation:
Common values are 1.0 on normal displays and 2.0 on "retina" displays. Higher values are also possible.
@Pl45m4 said in High DPI scaling detection:
Isn't the pixelRatio already listed in your table?
Correct, but as you can see that value doesn't tell what scaling is set up on Windows. There is just a point where it switches from one to two - and there the resolution of the screen is halfed.
On startup the QGuiApplication get a font with a pixel-size that somehow reflects the scaling of the primary screen. But that font size isn't updated when the application is moved to a screen with a different scaling factor. Even more puzzling: The texts in the tab-bar and in the menu-bar appear in obvious different sizes - but asking them programatically they claim to have the same point size (the initial point-size of the app)
-
Update:
The font size of the
QMenu
and theQTabBar
do not differ in the main windows constructor. But after waiting for the followup events to be processed these fonts differ in fact.To get the
QTabBar
having the same font size as theQMenu
it doesn't help to just assign the menus font to the it. It is necessary to explicitly assign the pointSize to the font before assigning it to the destination widget (here theQTabBar
).Additionally one can get the
QFontMetrics::height()
for concrete values.I mark this solved.
Best
Jazzco