Skip to content

GH-3666 Fix multi-monitor dpi scaling on windows #3684

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 26, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 17 additions & 1 deletion application/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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

Expand Down