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
This commit is contained in:
KGB-8375 2021-03-24 13:36:48 -04:00 committed by KGB-8375
parent cbc973a5af
commit 34bf688479

View File

@ -4,6 +4,10 @@
#include <InstanceList.h>
#include <QDebug>
#ifdef Q_OS_WIN
#include<windows.h>
#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