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

QScrollArea fails to re-layout widgets correctly in high DPI environments



    • Bug
    • Resolution: Done
    • P2: Important
    • 6.2.0 Beta3, 6.3.0 Alpha
    • 5.12.10, 5.14.2, 5.15.2
    • GUI: High-DPI
    • None
    • Any windows system with multiple monitors attached, and having different scale factors set (e.g. 100% and 150%).
    • Windows
    • 6336b5350b68e6430a7585d6658a9d653689186f (qt/qtbase/dev) da68ad52104c67a39c8d8c8203ef6969b0a474f1 (qt/qtbase/6.2)


      This bug is very closely related to QTBUG-82312.

      If winId() is called in any widget managed by QScrollArea, the widget will fail to re-layout correctly when moved between mixed scale factor monitors on Windows.  The result is a garbled mess of what looks like the layouts from both scale factors, and is unusable.   This only happens if the Qt property AA_EnableHighDPIScaling is set on the application.

      Our applications need to be able to use winId() within widget hierarchies to accomplish tasks such as hooking into native events, and doing direct screen rendering on native windows.

      A fix was put in place for QTBUG-82312 that corrected those specific behaviors outlined in that defect, but appear to have now introduced these layout issues.  This behavior does not exist in Qt 5.9.9 or earlier. 

      I've attached a modified version of the program I provided in QTBUG-82312 that illustrates this behavior.  It simply draws a number of buttons on a widget, and shows how those get mangled when the widget is moved to a different scale factor monitor.   

      The call to winId() is on line 25 of MainView.cpp.  If this is commented out, the layout works correctly once more.


        1. 5_15_2 100 percent scale.PNG
          5_15_2 100 percent scale.PNG
          6 kB
        2. 5_15_2 150 percent scaling.PNG
          5_15_2 150 percent scaling.PNG
          13 kB
        3. child-windows-correct.png
          7 kB
        4. child-windows-incorrect.png
          7 kB
        5. qtbug89294.zip
          5 kB
        6. qtbug89294-qwindow.zip
          2 kB
        7. QtWinIdLayoutBug.zip
          4 kB

        Issue Links

          For Gerrit Dashboard: QTBUG-89294
          # Subject Branch Project Status CR V



              sorvig Morten Sørvig
              jeremyhp Jeremy Cook
              Veli-Pekka Heinonen Veli-Pekka Heinonen
              1 Vote for this issue
              8 Start watching this issue



                Gerrit Reviews

                  There are no open Gerrit changes