在 Qml 中,我可以使用以下命令开始拖动text/uri-list
mime 类型,以便启动从我的应用程序到文件资源管理器的复制操作,例如
Item {
id: draggable
anchors.fill: parent
Drag.active: mouseArea.drag.active
Drag.hotSpot.x: 0
Drag.hotSpot.y: 0
Drag.mimeData: { "text/uri-list": "file:///home/myname/Desktop/avatar.jpeg" }
Drag.supportedActions: Qt.CopyAction
Drag.dragType: Drag.Automatic
Drag.onDragStarted: { }
Drag.onDragFinished: {
console.log("Time to copy")
}
} // Item
or
Item {
id: draggable
anchors.fill: parent
Drag.active: mouseArea.drag.active
Drag.hotSpot.x: 0
Drag.hotSpot.y: 0
Drag.mimeData: { "text/uri-list": "https://farm1.staticflickr.com/713/21777111068_e3310cfb94_k.jpg" }
Drag.supportedActions: Qt.CopyAction
Drag.dragType: Drag.Automatic
Drag.onDragStarted: { }
Drag.onDragFinished: {
console.log("Time to copy")
}
} // Item
(也可以看看Qt 快速示例 - 外部拖放 http://doc.qt.io/qt-5/qtquick-externaldraganddrop-example.html)
鉴于此效果很好file:
and http:
URIs.
然而,我的真实数据不能作为 URI 提供,而是存储在数据库中。我无法快速存储到临时温度,因为这可能需要几秒钟的时间,并且用户不希望在开始拖动时出现延迟。
是否有可能在放置后获取目标 URI 并自己进行复制?还是只有目标才能进行复制?
在后一种情况下,我是否需要通过内部 HTTP 服务器提供我的数据?我如何知道 Linux、Windows 和 OS X 上的文件浏览器支持哪种 URI 方案?
我会使用类似的东西:
Drag.mimeData: { "text/uri-list": "http://localhost:8080/datarepository?id=12345" }
然后我将在应用程序内 HTTP 服务器上提供请求的数据(然后可以轻松提取 ID 等于12345
在我的数据库示例中)...(一旦复制操作开始,如果您的用户在系统从数据库中提取对象时等待几秒钟,我不认为这是一种耻辱)。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)