From 35dce99b5664e47b2210c2dfe36300376e837f1d Mon Sep 17 00:00:00 2001 From: Alexandru Croitor Date: Wed, 27 Jan 2016 13:45:55 +0100 Subject: 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 --- src/widgets/itemviews/qabstractitemview.cpp | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) (limited to 'src/widgets') 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(); -- cgit v1.2.3