Skip to content

Commit

Permalink
QT: set PassThrough scaling policy for HighDpi displays
Browse files Browse the repository at this point in the history
  • Loading branch information
dyfer committed Apr 4, 2020
1 parent 0492dc4 commit a8e4520
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
6 changes: 6 additions & 0 deletions QtCollider/interface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,12 @@ void QtCollider::init() {
static char* qcArgv[1] = { qcArg0 };

QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
// In order to scale the UI properly on Windows with display scaling like 125% or 150%
// we need to disable scale factor rounding
// This is only available in Qt >= 5.14
#if (QT_VERSION >= QT_VERSION_CHECK(5, 14, 0))
QGuiApplication::setHighDpiScaleFactorRoundingPolicy(Qt::HighDpiScaleFactorRoundingPolicy::PassThrough);
#endif // QT_VERSION

QcApplication* qcApp = new QcApplication(qcArgc, qcArgv);

Expand Down
7 changes: 7 additions & 0 deletions editors/sc-ide/core/main_function.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,13 @@ using namespace ScIDE;

int main(int argc, char* argv[]) {
QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
// In order to scale the UI properly on Windows with display scaling like 125% or 150%
// we need to disable scale factor rounding
// This is only available in Qt >= 5.14
#if (QT_VERSION >= QT_VERSION_CHECK(5, 14, 0))
QGuiApplication::setHighDpiScaleFactorRoundingPolicy(Qt::HighDpiScaleFactorRoundingPolicy::PassThrough);
#endif // QT_VERSION

QApplication app(argc, argv);

QStringList arguments(QApplication::arguments());
Expand Down

0 comments on commit a8e4520

Please sign in to comment.