diff --git a/src/corelib/global/qnamespace.h b/src/corelib/global/qnamespace.h index fc5207fa257dd7824e0ae12e240b3e242d1610f3..9381f01639fe34143c75f482d6126536be104d0f 100644 --- a/src/corelib/global/qnamespace.h +++ b/src/corelib/global/qnamespace.h @@ -496,6 +496,7 @@ public: AA_UseSoftwareOpenGL = 17, AA_ShareOpenGLContexts = 18, AA_SetPalette = 19, + AA_NoHighDpiScaling = 20, // Add new attributes before this line AA_AttributeCount diff --git a/src/corelib/global/qnamespace.qdoc b/src/corelib/global/qnamespace.qdoc index 970e1b1f426dfceed64a6a94df8b1a24122d159b..4aed887b195e2360ad59cb3251f823d2ad44db17 100644 --- a/src/corelib/global/qnamespace.qdoc +++ b/src/corelib/global/qnamespace.qdoc @@ -197,6 +197,11 @@ \value AA_SetPalette Indicates whether a palette was explicitly set on the QApplication/QGuiApplication. This value has been added in Qt 5.5. + \value AA_NoHighDpiScaling Disables all high-DPI scaling in Qt, exposing window + system coordinates. Note that the window system may do its own scaling, + so this does not guarantee that QPaintDevice::devicePixelRatio() will + be equal to 1. This value has been added in Qt 5.6. + The following values are obsolete: \value AA_ImmediateWidgetCreation This attribute is no longer fully diff --git a/src/gui/kernel/qhighdpiscaling.cpp b/src/gui/kernel/qhighdpiscaling.cpp index e574a793701d48194d32fe03981b8816ab1e941f..46c9f671df77cf7289a85f3887e46fc4ada18c1a 100644 --- a/src/gui/kernel/qhighdpiscaling.cpp +++ b/src/gui/kernel/qhighdpiscaling.cpp @@ -142,6 +142,11 @@ QDpi QHighDpiScaling::m_logicalDpi; // The scaled logical DPI of the primary scr */ void QHighDpiScaling::initHighDpiScaling() { + if (QCoreApplication::testAttribute(Qt::AA_NoHighDpiScaling)) { + m_factor = 1; + m_active = false; + return; + } m_factor = initialScaleFactor(); bool usePlatformPluginPixelDensity = qEnvironmentVariableIsSet(autoScreenEnvVar) || qgetenv(legacyDevicePixelEnvVar).toLower() == "auto"; @@ -157,6 +162,9 @@ void QHighDpiScaling::initHighDpiScaling() void QHighDpiScaling::updateHighDpiScaling() { + if (QCoreApplication::testAttribute(Qt::AA_NoHighDpiScaling)) + return; + if (m_usePixelDensity && !m_pixelDensityScalingActive) { Q_FOREACH (QScreen *screen, QGuiApplication::screens()) { if (!qFuzzyCompare(screenSubfactor(screen->handle()), qreal(1))) {