summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorAlexandru Croitor <alexandru.croitor@theqtcompany.com>2016-01-27 13:45:55 +0100
committerAlexandru Croitor <alexandru.croitor@theqtcompany.com>2016-03-17 10:38:20 +0000
commit35dce99b5664e47b2210c2dfe36300376e837f1d (patch)
treea16715a32c0bf61c3e940e1ddc384464e82615ec /src
parentaa3008dfa1e3dfa0f6a35999ae62e4c012ad8089 (diff)
Fix QAbstractItemView dragged item pixmaps to be HighDPI aware.
When an item is rendered into a QPixmap sent to the QDrag implementation, make sure it's size is scaled with the current window's devicePixelRatio, so it does not appear blurry on high-dpi screens. Change-Id: Idf38c0993e8529aff7107ff1ac412de9cf10f311 Task-number: QTBUG-46068 Reviewed-by: Shawn Rutledge <shawn.rutledge@theqtcompany.com>
Diffstat (limited to 'src')
-rw-r--r--src/widgets/itemviews/qabstractitemview.cpp15
1 files changed, 14 insertions, 1 deletions
diff --git a/src/widgets/itemviews/qabstractitemview.cpp b/src/widgets/itemviews/qabstractitemview.cpp
index ad7be840d0..a126fef65e 100644
--- a/src/widgets/itemviews/qabstractitemview.cpp
+++ b/src/widgets/itemviews/qabstractitemview.cpp
@@ -4353,7 +4353,20 @@ QPixmap QAbstractItemViewPrivate::renderToPixmap(const QModelIndexList &indexes,
QItemViewPaintPairs paintPairs = draggablePaintPairs(indexes, r);
if (paintPairs.isEmpty())
return QPixmap();
- QPixmap pixmap(r->size());
+
+ qreal scale = 1.0f;
+
+ Q_Q(const QAbstractItemView);
+ QWidget *window = q->window();
+ if (window) {
+ QWindow *windowHandle = window->windowHandle();
+ if (windowHandle)
+ scale = windowHandle->devicePixelRatio();
+ }
+
+ QPixmap pixmap(r->size() * scale);
+ pixmap.setDevicePixelRatio(scale);
+
pixmap.fill(Qt::transparent);
QPainter painter(&pixmap);
QStyleOptionViewItem option = viewOptionsV1();