aboutsummaryrefslogtreecommitdiffstats
path: root/src/qmltest
diff options
context:
space:
mode:
authorTimur Pocheptsov <timur.pocheptsov@qt.io>2022-06-16 19:06:04 +0200
committerQt Cherry-pick Bot <cherrypick_bot@qt-project.org>2022-06-18 00:17:14 +0000
commit3af1c96d7976938b30c1e4d141a84c03d07c7a67 (patch)
treee780061de9854baff177d5cf7b5ff730fd03b6e2 /src/qmltest
parenta6bd340fa93ba351537929a3fa2ad4c00e4e8c58 (diff)
Quick test lib: Account for DPR when grabbing sub-image
Otherwise, the item that we are trying to grab lives in non-pixel coordinates, so we end up with a sub-image that is smaller than needed and incorrectly translated. Fixes: QTBUG-98914 Change-Id: Ic36b4d2cb0de5ef50a726c2ee3207c95d06b6a05 Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io> (cherry picked from commit 47790977f53400d981d7086b8594937ad6ee8e20) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
Diffstat (limited to 'src/qmltest')
-rw-r--r--src/qmltest/quicktestresult.cpp3
1 files changed, 2 insertions, 1 deletions
diff --git a/src/qmltest/quicktestresult.cpp b/src/qmltest/quicktestresult.cpp
index 3310f90c2b..0ebc3f42b2 100644
--- a/src/qmltest/quicktestresult.cpp
+++ b/src/qmltest/quicktestresult.cpp
@@ -773,7 +773,8 @@ QObject *QuickTestResult::grabImage(QQuickItem *item)
if (item && item->window()) {
QQuickWindow *window = item->window();
QImage grabbed = window->grabWindow();
- QRectF rf(item->x(), item->y(), item->width(), item->height());
+ const auto dpi = grabbed.devicePixelRatio();
+ QRectF rf(item->x() * dpi, item->y() * dpi, item->width() * dpi, item->height() * dpi);
rf = rf.intersected(QRectF(0, 0, grabbed.width(), grabbed.height()));
QObject *o = new QuickTestImageObject(grabbed.copy(rf.toAlignedRect()));
QQmlEngine::setContextForObject(o, qmlContext(this));