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

Qt doesn't handle multiple monitors with different DPI

    XMLWordPrintable

Details

    • Bug
    • Resolution: Done
    • P2: Important
    • 5.9.0 Beta 1
    • 5.4.0, 5.5.0
    • QPA: Windows
    • None
    • Windows 10.
    • f3a4b4258f2d207b5a8e73d62822a3afe1bf8a72 cd2b5f1ada07fc7a5ec31e3b48a7fdf76bf62020

    Description

      I have attached a very simple Qt app.

      1. On Windows 10, set up a multi-monitor display.
      2. Keep the main monitor at 100% and set the second to 200% for text scaling. This can be done in display settings.
      3. Launch the attached app.

      Expected: The QLabel, and main window grow as you move it to the higher DPI screen and shrink when you move it back.

      Actual: The text gets bigger, but the label's size doesn't change (so it clips) and the main window doesn't grow bigger.

      Further investigation reveals a few conclusions

      1. QFont created with default constructor should rare if ever be used. It uses the App's DPI. The QWidget you are using the font with should be passed in so it can get the proper DPI from it. Debugging the QFont revealed that most of the QFont's moving around (except painters) get the wrong DPI set.
      2. Widgets are caching their size hints, like QLabel and not reacting to changed screen DPI. When the DPI changes, their size hint cache should be invalidated
      3. Qt in general doesn't handle switching DPI's.

      Qt Designer, Creator and Assistant show the same problems becoming unusable when moving to a high DPI screen. The scenario above covers the user with their high DPI laptop connected to a standard DPI projector, or the user with only one high DPI monitor connected to their PC (and one normal).

      There are a lot more problems then this QLabel. This is the results of debugging this one case.

      Attachments

        1. ApplicationFrameHost_2020-06-16_15-08-42.png
          ApplicationFrameHost_2020-06-16_15-08-42.png
          22 kB
        2. AtomixDevelopment_2020-06-16_14-25-08.png
          AtomixDevelopment_2020-06-16_14-25-08.png
          5 kB
        3. devenv_2020-06-16_14-53-34.png
          devenv_2020-06-16_14-53-34.png
          39 kB
        4. explorer_2020-06-16_15-13-50.png
          explorer_2020-06-16_15-13-50.png
          5 kB
        5. High DPI not resized.png
          High DPI not resized.png
          3 kB
        6. HighDPITest_2020-06-16_15-09-18.png
          HighDPITest_2020-06-16_15-09-18.png
          8 kB
        7. HighDPITest_2020-06-16_15-49-45.png
          HighDPITest_2020-06-16_15-49-45.png
          8 kB
        8. HighDPITest.zip
          4 kB
        9. image-2020-06-16-14-56-01-920.png
          image-2020-06-16-14-56-01-920.png
          10 kB
        10. image-2020-06-16-14-56-11-947.png
          image-2020-06-16-14-56-11-947.png
          5 kB
        11. Normal DPI.png
          Normal DPI.png
          3 kB
        12. release.zip
          8.52 MB
        13. test.zip
          6 kB
        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            ogoffart Olivier Goffart (Woboq GmbH)
            nteeuwentableau Nicolas Teeuwen
            Votes:
            13 Vote for this issue
            Watchers:
            19 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes