From 34bf68847998cdfff1360d6ed04339d36894c00d Mon Sep 17 00:00:00 2001 From: KGB-8375 <60853993+KGB-8375@users.noreply.github.com> Date: Wed, 24 Mar 2021 13:36:48 -0400 Subject: [PATCH] GH-3666 Fix multi-monitor dpi scaling on windows Disable qt 5.6 DPI scaling and use windows' builtin DPI scaling, which works much better on multi-monitor setups --- application/main.cpp | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/application/main.cpp b/application/main.cpp index b0360c7e..e29f3453 100644 --- a/application/main.cpp +++ b/application/main.cpp @@ -4,6 +4,10 @@ #include #include +#ifdef Q_OS_WIN + #include +#endif + // #define BREAK_INFINITE_LOOP // #define BREAK_EXCEPTION // #define BREAK_RETURN @@ -29,7 +33,19 @@ int main(int argc, char *argv[]) #endif #if (QT_VERSION >= QT_VERSION_CHECK(5, 6, 0)) - QApplication::setAttribute(Qt::AA_EnableHighDpiScaling); + #ifdef Q_OS_WIN + BOOL (__stdcall *pFn)(void); + HINSTANCE hInstance=LoadLibrary("user32.dll"); + if(hInstance) { + pFn = (BOOL (__stdcall*)(void))GetProcAddress(hInstance, "SetProcessDPIAware"); + if(pFn) + pFn(); + FreeLibrary(hInstance); + } + QApplication::setAttribute(Qt::AA_DisableHighDpiScaling); + #else + QApplication::setAttribute(Qt::AA_EnableHighDpiScaling); + #endif QGuiApplication::setAttribute(Qt::AA_UseHighDpiPixmaps); #endif