From 8ebe8ae35ee7556de0749bc27737ced7c61f5153 Mon Sep 17 00:00:00 2001 From: Gabriel de Dietrich Date: Fri, 5 Aug 2016 16:12:00 -0700 Subject: HiDPI Drag and Drop: Properly render the default image on Mac MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This is only when the attached MIME data contains text, and we fall back to rendering that text into a pixmap. It requires getting the device pixel ratio from the source which, for now, may be a QWidget or a QWindow. Other cases may exist, but that would bring more dependencies than desired. Similarly, it fixes the draggabletext example. Other examples would require either to get updated pixmaps or change substantially in order to support HiDPI (e.g., the fridgemagnets example). Change-Id: I66198214233e3e06c87505744e2aaa9691fe1bb6 Reviewed-by: Filipe Azevedo Reviewed-by: Timur Pocheptsov Reviewed-by: Morten Johan Sørvig --- examples/widgets/draganddrop/draggabletext/dragwidget.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'examples/widgets/draganddrop') diff --git a/examples/widgets/draganddrop/draggabletext/dragwidget.cpp b/examples/widgets/draganddrop/draggabletext/dragwidget.cpp index 36c4df2e43..77262e5b29 100644 --- a/examples/widgets/draganddrop/draggabletext/dragwidget.cpp +++ b/examples/widgets/draganddrop/draggabletext/dragwidget.cpp @@ -150,7 +150,9 @@ void DragWidget::mousePressEvent(QMouseEvent *event) mimeData->setData(hotSpotMimeDataKey(), QByteArray::number(hotSpot.x()) + ' ' + QByteArray::number(hotSpot.y())); - QPixmap pixmap(child->size()); + qreal dpr = window()->windowHandle()->devicePixelRatio(); + QPixmap pixmap(child->size() * dpr); + pixmap.setDevicePixelRatio(dpr); child->render(&pixmap); QDrag *drag = new QDrag(this); -- cgit v1.2.3