-
Bug
-
Resolution: Unresolved
-
P2: Important
-
None
-
5.1.0 Beta 1
-
None
-
Checked on Win and Linux, reproducible on the both. Probably on Mac as well.
When doing a drag-n-drop in-process, the qmimedata only has application/x-qt-image and none of the actual portable image formats, so this implementation fails.
When doing a drag-n-drop from one process to another (you can test this by running the program twice), everything works fine, image/png and all other image formats are in the qmimedata.
Can be reproduced with the following:
#include <QtCore> #include <QtGui> #include <QtWidgets> class MyWidget : public QLabel { public: MyWidget(): QLabel(0) { setMinimumSize(QSize(200, 200)); setAcceptDrops(true); } protected: virtual void dropEvent(QDropEvent* event) { const QMimeData* mimeData = event->mimeData(); qDebug() << "allFormats:" << mimeData->formats(); const QString mime = "image/png"; const QByteArray data = mimeData->data(mime); if(data.isEmpty()) { qWarning("Bug: image/png data is not available when the drag is from the same process!"); } QPixmap pix; if (!pix.loadFromData(data)) qWarning("loading failed"); setPixmap(pix); event->acceptProposedAction(); } virtual void dragEnterEvent(QDragEnterEvent* event) { event->accept(); } virtual void dragMoveEvent(QDragMoveEvent* event) { event->accept(); } virtual void mouseMoveEvent(QMouseEvent*) { QDrag* drag = new QDrag(this); QMimeData* mimeData = new QMimeData; mimeData->setText(text()); QImage img("mail-message.png"); Q_ASSERT(!img.isNull()); mimeData->setImageData(img); drag->setPixmap(QPixmap::fromImage(img)); drag->setMimeData(mimeData); drag->exec(); } }; int main( int argc, char ** argv ) { QApplication app(argc, argv); MyWidget w1; w1.setText("Please drag from this widget"); w1.show(); MyWidget w2; w2.setText("Drop here"); w2.show(); return app.exec(); }
- relates to
-
QTBUG-24622 Qt 4.8 broke custom QMimeData classes that also return application/x-qt-image
-
- Closed
-