path: root/examples/widgets/draganddrop
diff options
authorGabriel de Dietrich <>2016-08-05 16:12:00 -0700
committerGabriel de Dietrich <>2016-08-09 18:22:03 +0000
commit8ebe8ae35ee7556de0749bc27737ced7c61f5153 (patch)
tree9ecbdf77099629acd09fe1d127da7f379999c0b9 /examples/widgets/draganddrop
parentdb79b89899e6537d540e290beaed263c46e3a885 (diff)
HiDPI Drag and Drop: Properly render the default image on Mac
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 <>
Diffstat (limited to 'examples/widgets/draganddrop')
1 files changed, 3 insertions, 1 deletions
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)
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);
QDrag *drag = new QDrag(this);