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>
bb10
Alexandru Croitor 2016-01-27 13:45:55 +01:00
parent aa3008dfa1
commit 35dce99b56
1 changed files with 14 additions and 1 deletions

View File

@ -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();