diff options
author | Morten Sørvig <morten.sorvig@qt.io> | 2022-04-27 19:15:00 +0200 |
---|---|---|
committer | Morten Sørvig <morten.sorvig@qt.io> | 2022-05-19 02:28:38 +0200 |
commit | e3201e712444e75d8f23660b23212dea020ba06b (patch) | |
tree | ab36098c7d84666406e7baf394bb8b8c0b1ee634 /src/widgets/styles/qwindowsstyle.cpp | |
parent | 2a34d4bc66385a008c334674de870e8a13afd05c (diff) |
windows: make native styles support QT_SCALE_FACTOR
Calculate the native metrics scale factor using DPI from the screen
instead of using devicePixelRatio from the widget.
This way the native metrics scale factor becomes independent
of whatever modifications QtGui applies to the DPR. This matches
its use case of scaling native metrics returned by win32 API.
Task-number: QTBUG-86344
Change-Id: I0d3c73956520e2bc4a56b23ea3cb8e1f0c36fcf1
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
Reviewed-by: Oliver Wolff <oliver.wolff@qt.io>
Diffstat (limited to 'src/widgets/styles/qwindowsstyle.cpp')
-rw-r--r-- | src/widgets/styles/qwindowsstyle.cpp | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/src/widgets/styles/qwindowsstyle.cpp b/src/widgets/styles/qwindowsstyle.cpp index d842dec718..08134b5e12 100644 --- a/src/widgets/styles/qwindowsstyle.cpp +++ b/src/widgets/styles/qwindowsstyle.cpp @@ -373,7 +373,10 @@ static QScreen *screenOf(const QWidget *w) // and account for secondary screens with differing logical DPI. qreal QWindowsStylePrivate::nativeMetricScaleFactor(const QWidget *widget) { - qreal result = qreal(1) / QWindowsStylePrivate::devicePixelRatio(widget); + const QPlatformScreen *screen = screenOf(widget)->handle(); + const qreal scale = screen ? (screen->logicalDpi().first / screen->logicalBaseDpi().first) + : QWindowsStylePrivate::appDevicePixelRatio(); + qreal result = qreal(1) / scale; if (QGuiApplicationPrivate::screen_list.size() > 1) { const QScreen *primaryScreen = QGuiApplication::primaryScreen(); const QScreen *screen = screenOf(widget); |