QT_ENABLE_HIGHDPI_SCALING misbehaving when windows scaling is set to 200%
-
Hi all,
Qt 6.5.3, Windows 10.
I'm getting some very strange results when combining large scale factors.
Most notably I am seeing different elements scale themselves differently, and it looks very strange when displayed.Perhaps the most obvious one is a collection of radio buttons.
This is the radio buttons with windows scaling @ 100%, and no Application scaling
This is windows scaling @ 100% and 200% application scaling, it seems correct at about 2x in both directions.
This is windows scaling @ 200% and No app Scaling, again basically correct with a 2x in each direction.
This is the Problem.
Windows scaling @ 200% and app scaling @ 200%, whilst the text appears to be the correct size, the size of the actual radio button icon is much larger than it should be and throws off the rest of the placement and layout.
I am using the following code to disable the host OS scaling and force my own scaling, as required.
float ratio = 0; // 2.0; if(ratio > 0) { qputenv("QT_ENABLE_HIGHDPI_SCALING", "0"); // Disable host OS scaling if(ratio > 1.0) qputenv("QT_SCALE_FACTOR", QString::number(ratio).toLatin1()); } Application app(argc, argv); return app.exec();
So when I am doing application scaling i am setting the QT_ENABLE_HIGHDPI_SCALING to 0, to disable the Host scaling.
Now for the most part this seems to be working as expected, it is just in a few items that I run into this problem.
Other places I have run into a similar issue, are with a QLineEdit, that seems to be taller than it should be,
and a QLabel which is also being drawn too tall.Am I doing something wrong with my usage of QT_ENABLE_HIGHDPI_SCALING ?
It seems to be behaving as expected for most use cases, ie if I have my windows scaling set to 150%, and my application scaling set to 125%
I get the 125% from my app with no extra windows scaling. Again if windows is @ 150%, and my app is at 125% i get the resulting 125% scale as expected.
Are there some extra rules I am not aware of when laying out GUI items for this sort of usage?Lastly I have tested the dprgadget sample app as provided as part of the SDK / Creator examples, and it too throws up some unusual behavior.
I modified the dprgadget app to have the same custom scaling as my app, prior to init'ing the QApplication and showing the DprWidget itself.
I then recorded the QWindow size and native size values from the displayed application.Here are my results:
QWindow size nativeSize Windows 100% 457, 431 457,431 NO App scaling Windows 100% 458, 438 916,876 2.0 App scaling Windows 200% 458, 438 916,876 No App scaling Windows 200% 916, 860 1832, 1720 2.0 App scaling
Pasted as code to preserve some of the formatting.
So again, the last example clearly has some problems with the way it is calculating the size of the window?
It still displays a big fat 2, but it looks like, and the numbers indicate it's scaling more like 4x than 2x?So it looks to me like in some situations the host OS is not being correctly disabled or ignored by the Qt rendering code? But I'm just making a wild guess?
Regards,
James -
Hi,
Can you check with a more recent version of Qt ?
If memory serves well, there have been multiple fixes for high dpi. -
I've checked with a newer version of Qt, specifically Qt 6.8.3.
and the same problem persists :(
If anything it's possibly worse.
The windows 200% and 2.0 for app scaling window is so large I cant even see the part of the dialog where it displays the native size. -
I've checked with a newer version of Qt, specifically Qt 6.8.3.
and the same problem persists :(
If anything it's possibly worse.
The windows 200% and 2.0 for app scaling window is so large I cant even see the part of the dialog where it displays the native size.@Jammin44fm Latest Qt version is 6.9.1
-
I don't see a problem with your numbers. 45722=1828 which matches more or less your 1832.
Qt does not ignore anything here.
please provide a minimal compileable example of your problem. -
I don't see a problem with your numbers. 45722=1828 which matches more or less your 1832.
Qt does not ignore anything here.
please provide a minimal compileable example of your problem.Can you elaborate on "Qt does not ignore anything here."
The docs at high dpi state...
"QT_ENABLE_HIGHDPI_SCALING Set to 0 to disable high-dpi scaling; "
I took this to mean that no OS level scaling will be applied.
That is, my application will fully ignore whatever setting the user has specified in windows for the scale setting for that display.Perhaps I am wrong though? However, If this is the case I would have expected the last picture I provided to be a full 4x the width and height of the original image?
Looking at the value displayed by dprgadget, it is always either 1 or 2, never 4.
In my case of windows scaling set to 200% and application scaling set to 2.0,
I would expect it to display 4, which would make sense with the 4x in length and width,
but it still shows 2?
It seems like the value displayed can account for the Host OS scaling level OR, the QT_SCALE_FACTOR value set, but not for both. However the final size of the window displayed IS effected by both these values. -
Can you elaborate on "Qt does not ignore anything here."
The docs at high dpi state...
"QT_ENABLE_HIGHDPI_SCALING Set to 0 to disable high-dpi scaling; "
I took this to mean that no OS level scaling will be applied.
That is, my application will fully ignore whatever setting the user has specified in windows for the scale setting for that display.Perhaps I am wrong though? However, If this is the case I would have expected the last picture I provided to be a full 4x the width and height of the original image?
Looking at the value displayed by dprgadget, it is always either 1 or 2, never 4.
In my case of windows scaling set to 200% and application scaling set to 2.0,
I would expect it to display 4, which would make sense with the 4x in length and width,
but it still shows 2?
It seems like the value displayed can account for the Host OS scaling level OR, the QT_SCALE_FACTOR value set, but not for both. However the final size of the window displayed IS effected by both these values.@Jammin44fm said in QT_ENABLE_HIGHDPI_SCALING misbehaving when windows scaling is set to 200%:
QT_ENABLE_HIGHDPI_SCALING
"This variable is intended for testing purposes only, and we do not recommend setting it on a permanent basis."
So don't use it...