path: root/src/widgets
diff options
authorMorten Johan Sørvig <>2020-02-20 11:25:49 +0100
committerMorten Johan Sørvig <>2020-02-21 10:38:58 +0100
commit4e1c41a26eaa51ebb133e9c846e8e93bbe318a2e (patch)
treea858ed1a74c636360bcbc7b12cb67e47e3a9d170 /src/widgets
parentfb6acf08bbd7a68d027282251747620b942bd1d6 (diff)
QStyle: Use primary screen DPI as default DPI
Change d603ee68 made the default DPI be 96, for cases where a style option is not provided. This causes inconsistencies, since there are in fact several cases where QStyle API is called without a style option. Restore historical Qt behavior of using the primary screen DPI. Single-screen systems should now be consistent, as before. Task-number: QTBUG-82356 Change-Id: I849934ca2e5604b9fb2f045ed4f6058f3e0426ff Reviewed-by: Friedemann Kleint <>
Diffstat (limited to 'src/widgets')
1 files changed, 6 insertions, 0 deletions
diff --git a/src/widgets/styles/qstylehelper.cpp b/src/widgets/styles/qstylehelper.cpp
index 9477ca86da..6016224faa 100644
--- a/src/widgets/styles/qstylehelper.cpp
+++ b/src/widgets/styles/qstylehelper.cpp
@@ -101,7 +101,13 @@ Q_WIDGETS_EXPORT qreal dpi(const QStyleOption *option)
if (option)
return option->fontMetrics.fontDpi();
+ // Fall back to historical Qt behavior: hardocded 72 DPI on mac,
+ // primary screen DPI on other platforms.
+#ifdef Q_OS_DARWIN
return qstyleBaseDpi;
+ return qt_defaultDpiX();
Q_WIDGETS_EXPORT qreal dpiScaled(qreal value, qreal dpi)