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

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

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Not Evaluated
    • Resolution: Out of scope
    • Affects Version/s: 5.7.0
    • Fix Version/s: None
    • Component/s: QPA: Windows
    • Labels:
      None
    • Environment:
      Windows 10

      Description

      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
      

        Attachments

          Issue Links

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

            Activity

              People

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

                Dates

                Created:
                Updated:
                Resolved:

                  Gerrit Reviews

                  There are no open Gerrit changes