From ffc8aac684e97bad1fb598883fa05ae66f7f1e4c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Morten=20Johan=20S=C3=B8rvig?= Date: Wed, 12 Mar 2014 11:01:26 +0100 Subject: [PATCH] Fix high-dpi QGraphicsPixmapItem bounding rects. QGraphicsPixmapItem did not take the pixmaps devicePixelRatio into account when calculating the bounding rect. As a consequence, a 512x512@2x pixmap would get a 512x512 bounding size instead of the correct 256x256 bounding size. Task-number: QTBUG-37008 Change-Id: I266e418b7e5d92bf1d4c96bd9380a27708dc2b4a Reviewed-by: Gabriel de Dietrich Reviewed-by: Andreas Aardal Hanssen --- src/widgets/graphicsview/qgraphicsitem.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/widgets/graphicsview/qgraphicsitem.cpp b/src/widgets/graphicsview/qgraphicsitem.cpp index 292b0419ca..f1b3d95f9c 100644 --- a/src/widgets/graphicsview/qgraphicsitem.cpp +++ b/src/widgets/graphicsview/qgraphicsitem.cpp @@ -9592,9 +9592,9 @@ QRectF QGraphicsPixmapItem::boundingRect() const return QRectF(); if (d->flags & ItemIsSelectable) { qreal pw = 1.0; - return QRectF(d->offset, d->pixmap.size()).adjusted(-pw/2, -pw/2, pw/2, pw/2); + return QRectF(d->offset, d->pixmap.size() / d->pixmap.devicePixelRatio()).adjusted(-pw/2, -pw/2, pw/2, pw/2); } else { - return QRectF(d->offset, d->pixmap.size()); + return QRectF(d->offset, d->pixmap.size() / d->pixmap.devicePixelRatio()); } }