diff --git a/src/frontends/qt/GuiApplication.cpp b/src/frontends/qt/GuiApplication.cpp index 6395f8e98a..fc2210aa22 100644 --- a/src/frontends/qt/GuiApplication.cpp +++ b/src/frontends/qt/GuiApplication.cpp @@ -63,6 +63,7 @@ #include "support/convert.h" #include "support/debug.h" #include "support/ExceptionMessage.h" +#include "support/environment.h" #include "support/FileName.h" #include "support/filetools.h" #include "support/ForkedCalls.h" @@ -180,6 +181,19 @@ frontend::Application * createApplication(int & argc, char * argv[]) AllowSetForegroundWindow(ASFW_ANY); #endif +#if QT_VERSION >= QT_VERSION_CHECK(5, 6, 0) + // Attribute Qt::AA_EnableHighDpiScaling must be set before QCoreApplication is created + if (getEnv("QT_ENABLE_HIGHDPI_SCALING").empty() + && getEnv("QT_AUTO_SCREEN_SCALE_FACTOR").empty()) + QApplication::setAttribute(Qt::AA_EnableHighDpiScaling, true); +#endif + +#if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0) + // HighDPI scale factor policy must be set before QGuiApplication is created + if (getEnv("QT_SCALE_FACTOR_ROUNDING_POLICY").empty()) + QApplication::setHighDpiScaleFactorRoundingPolicy(Qt::HighDpiScaleFactorRoundingPolicy::PassThrough); +#endif + frontend::GuiApplication * guiApp = new frontend::GuiApplication(argc, argv); // I'd rather do that in the constructor, but I do not think that // the palette is accessible there.