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

Win: Scale factor is wrong for embedded widgets with displays with different DPI



    • Bug
    • Resolution: Unresolved
    • P2: Important
    • None
    • 6.3.1, 6.6.1
    • GUI: High-DPI, QPA: Windows
    • None
    • Windows 10, Windows 11
    • Windows


      We embed Qt controls into palettes of Adobe applications. A floating palette of Adobe Illustrator is the parent window of Qt controls. On Windows, when moving such palettes between displays with different scale factors (AKA DPI), e.g. 100% & 150%, then the wrong DPI of the primary screen is used, instead of the appropriate secondary screen. As a result, the Qt widgets get wrongly downscaled (or upscaled). The issue got revealed by Qt commits e8fabb29462e6ee268bde5267e3d7bca23addbb2 and 46039092bdabcea76f5899b492e3429d6b571bfa in QWindow::setGeometry(). When the user resizes the palette, its client area resizes and we (need to) resize QWidget representing the parent of all Qt widgets. QWindow::setGeometry(rect) gets called with the top-left coordinates typically being (0,0), because relative to the parent window.  d->screenForGeometry() yields the primary screen because of that. isTopLevel() returns true for embedded widgets, therefore d->setTopLevelScreen(newScreen, true) is wrongly called with the primary screen in newScreen. When this setTopLevelScreen() call is avoided, then the Qt widget gets moved to the left of the actual client area of the palette, caused by the wrong rect returned by QHighDpi::toNativeWindowGeometry(rect, this). My patch simply undoes the two aforementioned commits for embedded widgets. Probably not the best approach, however it works as expected on Windows and introduces no regressions on macOS.


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



            sorvig Morten Sørvig
            jan.patera Jan Patera
            1 Vote for this issue
            2 Start watching this issue



              Gerrit Reviews

                There are no open Gerrit changes