Merge pull request #3684 from KGB-8375/patch-1

GH-3666 Fix multi-monitor dpi scaling on windows
This commit is contained in:
Petr Mrázek 2021-03-26 20:36:28 +00:00 committed by GitHub
commit adf2301b2a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -4,6 +4,10 @@
#include <InstanceList.h> #include <InstanceList.h>
#include <QDebug> #include <QDebug>
#ifdef Q_OS_WIN
#include<windows.h>
#endif
// #define BREAK_INFINITE_LOOP // #define BREAK_INFINITE_LOOP
// #define BREAK_EXCEPTION // #define BREAK_EXCEPTION
// #define BREAK_RETURN // #define BREAK_RETURN
@ -29,7 +33,19 @@ int main(int argc, char *argv[])
#endif #endif
#if (QT_VERSION >= QT_VERSION_CHECK(5, 6, 0)) #if (QT_VERSION >= QT_VERSION_CHECK(5, 6, 0))
#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); QApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
#endif
QGuiApplication::setAttribute(Qt::AA_UseHighDpiPixmaps); QGuiApplication::setAttribute(Qt::AA_UseHighDpiPixmaps);
#endif #endif