Details
-
Bug
-
Status: Reported
-
P3: Somewhat important
-
Resolution: Unresolved
-
5.15.2, 6.0.3, 6.1.0 Beta3
-
None
-
None
-
The easiest way to reproduce is to have 2 monitors. Move the test application to the second one, put the DPI settings dialog on the first one. This way the application is not being obstructed and you can easily see the issue.
Description
This issue affects applications that wants to draw a custom frame instead of the standard system frame. The problem itself arises when the DPI scaling of the monitor is changed.
How to reproduce:
- Open the `simplebrowser` (QWidget-based browser) example in Qt Creator
- Set the High-DPI scaling policy in `main.cpp`:
QApplication::setHighDpiScaleFactorRoundingPolicy(Qt::HighDpiScaleFactorRoundingPolicy::PassThrough);
- Add the `FramelessWindowHint` flag to `BrowserWindow`:
setWindowFlag(Qt::FramelessWindowHint);
- Start the application
- Set the DPI scaling of the monitor to 100%
- Set the DPI scaling of the monitor to 125%
- Set the DPI scaling of the monitor to 100%
Expected result: the application scales properly, the widgets are re-drawn
Actual result: there are black areas where the widgets didn't repaint themselves, other areas are blurry or has other scaling artifacts.
What I did on the video (attachment):
- Set the DPI scaling of the monitor from 100% to 125%
- Set the DPI scaling of the monitor from 125% to 150%
- Set the DPI scaling of the monitor from 150% to 100% (in most cases the issue comes when changing the scale factor from a higher value to a lower one)
As you can see, some widgets has been re-drawn by hovering on them. Also there are scaling glitches on the rendered website in the web view.
Additionally this problem doesn't only come with `FramelessWindowHint`. In one of our applications we don't use that flag. Instead, we handle `WM_NCCALCSIZE` and use `DwmExtendFrameIntoClientArea`. (This method also removes the frame, but leaves the shadow and works with Aero snap). The result is the same.
If I change the DPI scale policy to one of the rounding ones, all widgets are re-drawn properly, but these policies cause incorrect font size vs. widget size ratios (too small text and huge widgets, or too small widgets and big text).
Since Qt 6 doesn't have WebEngine, I've made a simple QWidget application for this test, incorporating a label and a button in a layout. This application produces the same problems.