summaryrefslogtreecommitdiffstats
path: root/src/gui
diff options
context:
space:
mode:
authorMorten Johan Sørvig <morten.sorvig@qt.io>2021-03-04 15:30:48 +0100
committerMorten Johan Sørvig <morten.sorvig@qt.io>2021-03-16 13:11:06 +0100
commitad10fd2a6f78d48866e59f843acb0248120074ce (patch)
tree0ca67fea742f919873859b6ded5a1f75dd27ee85 /src/gui
parent0bd705d91bc7a883a90abf3a6a6f638301fe2f75 (diff)
Round physical dpi when calculating scale factor
(For the QT_USE_PHYSICAL_DPI use case) The physical DPI is nominally computed from the physical screen size, however when QT_USE_PHYSICAL_DPI is set that size has typically been overridden with a fake size by the user, such that the resulting DPI calculation will yield some specific integer DPI. Round this DPI value in order to arrive at a nice scale factor, e.g. 144/96 = 1.5 instead of 144.01/96 = 1.5001 Change-Id: I665394e98a818b3a8f46408f3193cac4411f458d Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
Diffstat (limited to 'src/gui')
-rw-r--r--src/gui/kernel/qhighdpiscaling.cpp2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/gui/kernel/qhighdpiscaling.cpp b/src/gui/kernel/qhighdpiscaling.cpp
index 3a70e5acf7..f93ec5fe76 100644
--- a/src/gui/kernel/qhighdpiscaling.cpp
+++ b/src/gui/kernel/qhighdpiscaling.cpp
@@ -293,7 +293,7 @@ qreal QHighDpiScaling::rawScaleFactor(const QPlatformScreen *screen)
QSize sz = screen->geometry().size();
QSizeF psz = screen->physicalSize();
qreal platformPhysicalDpi = ((sz.height() / psz.height()) + (sz.width() / psz.width())) * qreal(25.4 * 0.5);
- factor = qreal(platformPhysicalDpi) / qreal(platformBaseDpi.first);
+ factor = qRound(platformPhysicalDpi) / qreal(platformBaseDpi.first);
} else {
const QDpi platformLogicalDpi = QPlatformScreen::overrideDpi(screen->logicalDpi());
factor = qreal(platformLogicalDpi.first) / qreal(platformBaseDpi.first);