Dragging a link from a browser to a QML app

When a link is dragged from a browser on Window 10 platform it contains the page title, but they did not make it accessible in QML:

import QtQuick 2.15
import QtQuick.Controls 2.15

ApplicationWindow {
    visible: true
    width: 640
    height: 480
    title: qsTr("Scroll")
    id: root

    DropArea {
        id: dropArea;
        anchors.fill: parent
        onEntered: {
            root.color = "gray";
            drag.accept (Qt.LinkAction);
        }
        onDropped: {
            console.log(drop.urls)
            console.log(drop.text)
            //console.log(drop.formats[0])

            for(var i in drop.urls) {
                var url = drop.urls[i]
                console.log(Qt.resolvedUrl(url))
            }

            for (var i=0; i < drop.formats.length; i++)
                console.log(drop.getDataAsString(drop.formats[i]))

            //for (var f in Object.values(drop.formats))
            //    console.log(drop.getDataAsString(f))

            root.color = "white"
        }
        onExited: {
            root.color = "white";
        }
    }
}

the output is:

QML Debugger: Waiting for connection on port 64935...
qml: [https://developernote.com/2012/05/using-ado-net-entity-framework-with-mysql/]
qml: https://developernote.com/2012/05/using-ado-net-entity-framework-with-mysql/
qml: 
qml: https://developernote.com/2012/05/using-ado-net-entity-framework-with-mysql/
qml: 
qml: ?
qml: h
qml: 
qml: 
...

so the URL is accessible, but the page title is probably in a binary format.

The list of available formats:

application/x-qt-windows-mime;value="DragContext"
application/x-qt-windows-mime;value="DragImageBits"
text/x-moz-url
application/x-qt-windows-mime;value="FileGroupDescriptorW"
application/x-qt-windows-mime;value="FileContents"
text/uri-list
application/x-qt-windows-mime;value="UniformResourceLocatorW"
text/plain

Links:

Leave a Reply

Your email address will not be published. Required fields are marked *