Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-92833

HighDPI: Repainting issues with HighDpiScaleFactorRoundingPolicy::PassThrough and FramelessWindowHint

    XMLWordPrintable

Details

    • Bug
    • Resolution: Unresolved
    • P3: Somewhat important
    • None
    • 5.15.2, 6.0.3, 6.1.0 Beta3
    • 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.
    • Windows

    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:

      1. Open the `simplebrowser` (QWidget-based browser) example in Qt Creator
      2. Set the High-DPI scaling policy in `main.cpp`: 
        QApplication::setHighDpiScaleFactorRoundingPolicy(Qt::HighDpiScaleFactorRoundingPolicy::PassThrough);
        
      3. Add the `FramelessWindowHint` flag to `BrowserWindow`:
        setWindowFlag(Qt::FramelessWindowHint);
        
      4. Start the application
      5. Set the DPI scaling of the monitor to 100%
      6. Set the DPI scaling of the monitor to 125%
      7. 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):

      1. Set the DPI scaling of the monitor from 100% to 125%
      2. Set the DPI scaling of the monitor from 125% to 150%
      3. 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.

      Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            sorvig Morten Sørvig
            tomikaa87qt Tamas Karpati
            Veli-Pekka Heinonen Veli-Pekka Heinonen
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated:

              Gerrit Reviews

                There are no open Gerrit changes