Hi guys!
There is a QLabel on my ui form which is as an image (I set "pixmap" property). So now, I want to let the use to drag and drop this image to Windows Explorer and shop graphic application (like Photoshop). How to do that?!
]]>https://forum.qt.io/topic/67468/drag-and-drop-image-from-application-to-windows-explorerRSS for NodeSun, 07 Jun 2020 09:36:08 GMTWed, 25 May 2016 05:35:46 GMT60Hi guys!
There is a QLabel on my ui form which is as an image (I set "pixmap" property). So now, I want to let the use to drag and drop this image to Windows Explorer and shop graphic application (like Photoshop). How to do that?!
]]>https://forum.qt.io/post/329474https://forum.qt.io/post/329474Wed, 25 May 2016 06:14:20 GMTDid you read http://doc.qt.io/qt-5.6/dnd.html ?
]]>https://forum.qt.io/post/329489https://forum.qt.io/post/329489Wed, 25 May 2016 06:52:34 GMTHI
and for
"shop graphic application"
you can usehttp://doc.qt.io/qt-5/qdesktopservices.html

and openUrl

"If the URL is a reference to a local file (i.e., the URL scheme is "file") then it will be opened with a suitable application instead of a Web browser."

The interesting part here is the QMimeData::retrieveData() overload. This method gets called when a drop happens.

So when a drop to the filesystem happens the mimedata requests the data and calls retrieveData(). In there you write your pixmap data to a temporary image file. For that you can use QTemporaryFile class for example. Write the data to the temporary file and return the url to the file. Mime-Type: "text/uri-list"

Analog for the pixmap image. Simply return the QPixmap. Mime-Type: "image/png"
Actually it could also be necessary to return the PNG binary data. I am not sure. This can be done like this: