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

Windows are the wrong size when moved between monitors with different DPI

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Out of scope
    • Icon: Not Evaluated Not Evaluated
    • None
    • 5.7.0
    • QPA: Windows
    • None
    • Windows 10

      On windows, when you move a window between two monitors with differing DPI the window keeps the same raw pixel dimensions, so either the content ends up squashed or cut when moving from low DPI -> high DPI or the window ends up bigger than the screen in the other direction. The window should keep the same logical size relative to its content instead.

      For anyone else having this problem, as a workaround you can force system DPI scaling so the window is down/upscaled by windows when it's not on the primary display using the following code at the top of main():

      #ifdef _WIN32
        {
          typedef BOOL (*SetProcessDpiAwarenessT)(int value);
          QLibrary user32("user32.dll", NULL);
          SetProcessDpiAwarenessT SetProcessDpiAwarenessD =
              (SetProcessDpiAwarenessT)user32.resolve("SetProcessDpiAwarenessInternal");
          if (SetProcessDpiAwarenessD)
            SetProcessDpiAwarenessD(1); //PROCESS_PER_MONITOR_DPI_AWARE
        }
      #endif
      

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

            kleint Friedemann Kleint
            patstew Patrick Stewart
            Votes:
            0 Vote for this issue
            Watchers:
            9 Start watching this issue

              Created:
              Updated:
              Resolved:

                There are no open Gerrit changes