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

Windows: Qt doesn't respond to DPI changes if Qt window is having a non-Qt parent

    XMLWordPrintable

Details

    • Windows

    Description

      It looks like on Windows, the Qt neither reacts to nor provides any notifications to DPI changes, if the Qt window is not a top-level window but is embedded into a non-Qt parent.

      We have provided a minimum test example (see attached file). It is to be run from under a debugger on Windows with a breakpoint set inside the lambda at line 77. First, left-click on the red vector image inside the test app window. It will dump the current devicePixelRatio into the debug console (the dumping code is in line 39). Now change the system DPI setting in the Windows Settings to a different value (e.g. from 100% to 125%). Left-click the red vector image again to get the new devicePixelRatio dumped into console.

      Expected results:

      1. the DPI change notification breakpoint in line 77 is triggered
      2. the new DPI value in the console is correct
      3. the physical size of the red vector image is rescaled proportionally to the DPI change

      Observed results:

      1. the breakpoint is not triggered
      2. the new DPI value is the same as the old one
      3. the physical size of the red vector image is unchanged

      NB1. Depending on your Windows system configuration, changing the system DPI settings might require re-logging-in and refuse to work on-the-fly while the app is running. This seems to be the case if you have enabled the custom DPI scaling option on your system, so you might want to turn that one off.

      NB2. To confirm that this is related to the non-Qt parent window, you may comment out the setParent() call in line 73. In this case the test example works as expected in all the 3 aspects listed above.

      You can also run the two versions of this demo app (with setParent() and with commented out setParent()) side-by-side. When changing the system DPI ratio setting you can observe the Qt image changing its size in the app without setParent() call, as expected, while the one with the setParent() call doesn't change its size (as it doesn't respond to the DPI change).

      NB3. The primary actual use case is dragging the window from a monitor with one DPI ratio to another monitor with a different DPI ratio. But, as we found out, from the app's perspective it seems to be equivalent, and changing the system settings is easier to work with (esp. if you don't have a second monitor) and to interpret the visual results.

       

      Attachments

        Issue Links

          Activity

            People

              vestbo Tor Arne Vestbø
              aqn Vadim Zavalishin
              Votes:
              3 Vote for this issue
              Watchers:
              9 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: