Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. How to disable non client area scaling when attribute Qt::AA_DisableHighDpiScaling is set?
Forum Updated to NodeBB v4.3 + New Features

How to disable non client area scaling when attribute Qt::AA_DisableHighDpiScaling is set?

Scheduled Pinned Locked Moved Solved General and Desktop
5 Posts 3 Posters 1.0k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • O Offline
    O Offline
    Oliver Wu
    wrote on 5 Nov 2020, 14:43 last edited by Oliver Wu 11 May 2020, 14:52
    #1

    By default, Qt applications are set to Per-Monitor DPI Aware on Windows 10. I have an application that also disables the high dpi scaling, while, the non client areas, such as the title bar, are still scaled by Operating System.

    It seems Qt calls EnableNonClientDpiScaling if the dpi aware is Per-Monitor within WM_NCCREATE.

    Is there a way to avoid invoking the EnableNonClientDpiScaling and make the title bar not scaled?

    This is the screenshot. The monitor scaling level is 300%. The texts are displayed as normal (100% - 96 dpi). While, the title is displayed at 300%.
    3482be89-0026-4a38-9d4e-03d6c58ab5b4-image.png

    1 Reply Last reply
    0
    • B Offline
      B Offline
      Bonnie
      wrote on 7 Nov 2020, 03:27 last edited by Bonnie 11 Jul 2020, 03:29
      #2

      Searching from the source: https://code.woboq.org/qt5/qtbase/src/plugins/platforms/windows/qwindowscontext.cpp.html#_ZN15QWindowsContext29shouldHaveNonClientDpiScalingEPK7QWindow

      bool QWindowsContext::shouldHaveNonClientDpiScaling(const QWindow *window)
      {
          return QOperatingSystemVersion::current() >= QOperatingSystemVersion::Windows10
              && window->isTopLevel()
              && !window->property(QWindowsWindow::embeddedNativeParentHandleProperty).isValid()
      #if QT_CONFIG(opengl) // /QTBUG-62901, EnableNonClientDpiScaling has problems with GL
              && (window->surfaceType() != QSurface::OpenGLSurface
                  || QOpenGLContext::openGLModuleType() != QOpenGLContext::LibGL)
      #endif
             ;
      }
      

      Looks like the only way is to use a GL window.
      Or you should also file a bug report.

      1 Reply Last reply
      1
      • I Offline
        I Offline
        iamsergio
        wrote on 7 Nov 2020, 10:40 last edited by
        #3

        Try choosing the DPI awareness setting by passing -platform windows:dpiawareness=0,1,2 or setting the env var (don't have it handy right now) before creating QApplication.

        1 Reply Last reply
        0
        • O Offline
          O Offline
          Oliver Wu
          wrote on 10 Nov 2020, 01:55 last edited by Oliver Wu 11 Oct 2020, 02:13
          #4

          dpiawareness doesn't help. The unware (0) and per system(1) still scale the window by operating system. The Qt default value Per monitor (2) is correct. Meanwhile, if disable dpi scaling is specified explictly, in my opinion, the non-client area scaling should be displayed as well. Unless there are any other considerations.
          I've created a bug at https://bugreports.qt.io/browse/QTBUG-88348.

          1 Reply Last reply
          0
          • O Offline
            O Offline
            Oliver Wu
            wrote on 17 Nov 2020, 01:13 last edited by
            #5

            The requirement is to disable the NCA on windows 10. While, it seems Qt sets PMv2 for Win10 and Mircosoft doesn't provide an API to disable the NCA. Hence it is not possible at the moment.

            1 Reply Last reply
            0

            1/5

            5 Nov 2020, 14:43

            • Login

            • Login or register to search.
            1 out of 5
            • First post
              1/5
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • Users
            • Groups
            • Search
            • Get Qt Extensions
            • Unsolved