From 1f6346df1c9da52ac98556ea99b3978fa180bc11 Mon Sep 17 00:00:00 2001 From: Safiyyah Moosa Date: Tue, 11 Mar 2025 23:05:46 +0100 Subject: [PATCH] Doc: Mention how devicePixelRatio tracks changes Currently the QWindow::devicePixelRatio() documentation mentions that the device pixel ratio can change, but it does not explain how to track the changes. This patch adds that the QWindow instance receives the event of type QEvent::DevicePixelRatioChange when the device pixel ratio changes. Fixes: QTBUG-128182 Pick-to: 6.8 Change-Id: I2107015a07f30167c9f7324959b47ada0a75988d Reviewed-by: Volker Hilsheimer (cherry picked from commit ada114f8b37b62fe80332105507b1afc20424aa6) Reviewed-by: Qt Cherry-pick Bot --- src/gui/kernel/qwindow.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/gui/kernel/qwindow.cpp b/src/gui/kernel/qwindow.cpp index 0454bf8920e..6a3bb83495b 100644 --- a/src/gui/kernel/qwindow.cpp +++ b/src/gui/kernel/qwindow.cpp @@ -1391,12 +1391,15 @@ Qt::ScreenOrientation QWindow::contentOrientation() const for the window. This value is dependent on the screen the window is on, and may change when the window is moved. + The QWindow instance receives an event of type + QEvent::DevicePixelRatioChange when the device pixel ratio changes. + Common values are 1.0 on normal displays and 2.0 on Apple "retina" displays. \note For windows not backed by a platform window, meaning that create() was not called, the function will fall back to the associated QScreen's device pixel ratio. - \sa QScreen::devicePixelRatio() + \sa QScreen::devicePixelRatio(), QEvent::DevicePixelRatioChange */ qreal QWindow::devicePixelRatio() const {