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 withinWM_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 at300%
.
-
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. -
dpiawareness
doesn't help. Theunware
(0
) andper system
(1
) still scale the window by operating system. The Qt default valuePer 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.