Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

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



  • 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



  • 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.



  • 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.



  • 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.



  • 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.


Log in to reply