From 9240b9ace5929a86557e2e7118b0e441793cc505 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Morten=20S=C3=B8rvig?= Date: Tue, 8 Apr 2025 11:06:42 +0200 Subject: [PATCH] Discourage use of QScreen::devicePixelRatio() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Remove line about "common values" which is now not 100% accurate and uses the outdated "retina" term. Add note which encourages using QWindow::devicePixelRatio() to get the correct DPR value in all cases. Task-number: QTBUG-135612 Change-Id: I78e049cb2f0661b62bc3e2520a4b3cbf1fde241d Reviewed-by: David Edmundson Reviewed-by: Tor Arne Vestbø --- src/gui/kernel/qscreen.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/gui/kernel/qscreen.cpp b/src/gui/kernel/qscreen.cpp index 9822fc3e1dd..afe6de35305 100644 --- a/src/gui/kernel/qscreen.cpp +++ b/src/gui/kernel/qscreen.cpp @@ -278,8 +278,9 @@ qreal QScreen::logicalDotsPerInch() const Returns the ratio between physical pixels and device-independent pixels for the screen. - Common values are 1.0 on normal displays and 2.0 on "retina" displays. - Higher values are also possible. + This function may return a value that differs from QWindow::devicePixelRatio(), + for instance on Wayland when using fractional scaling, or if window properties + that affect surface resolution are set. Prefer using QWindow::devicePixelRatio(). \note On some platforms the devicePixelRatio of a window and the screen it is on can be different. Use this function only when you don't know which window you are targeting.