Details
-
Bug
-
Resolution: Unresolved
-
P1: Critical
-
None
-
6.7.0
-
None
Description
As I was implementing drag and drop support for my note-taking app I found out that dragging images from the browser to my app doesn't work on Windows (but works well on macOS and Linux).
One very easy way (but not comprehensive) to reproduce the issue is the following code:
import QtQuick Window { width: 640 height: 480 visible: true title: qsTr("Hello World") DropArea { anchors.fill: parent onEntered: (event) => { console.log(event.formats); } } }
on macOS and Linux, dragging an image from the browser to the app's window will produce the following output:
[text/uri-list,application/x-qt-image]
The "application/x-qt-image" format indicate that the mimeData holds an image data.
On Windows, on the other hand, the output is as follows:
[application/x-qt-windows-mime;value="DragContext",application/x-qt-windows-mime;value="DragImageBits",application/x-qt-windows-mime;value="chromium/x-renderer-taint",application/x-qt-windows-mime;value="FileGroupDescriptorW",application/x-qt-windows-mime;value="FileContents",text/x-moz-url,text/uri-list,application/x-qt-windows-mime;value="UniformResourceLocatorW",text/plain,text/html]
Here, "application/x-qt-image" isn't listed.
But I attached a more comprehensive approach that uses Krita's DeclarativeMimeData to get and pass the DeclarativeMimeData from QML to C++ and manipulate it there (since DragEvent QML doesn't have hasImage and imageData properties, which is very unfortunate btw and forces me and others to do all these shenanigans). The attached code shows that the QMimeData really doesn't hold and recognize image data when dragging an image from the browser or other apps on Windows.