5
在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
或
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 Quick Examples - externaldraganddrop)
这工作正常,赋予file:
和http:
的URI。
但是我的真实数据不能作为URI使用,但存储在数据库中。我无法快速存储到临时数据,因为这可能需要几秒钟的时间,并且用户在开始拖动时不想延迟。
是否有可能在删除后获取目标URI并自己复制?或者只能对目标进行复制?
在后面的例子中,我是否需要通过内部HTTP服务器使我的数据可用?我怎么知道Linux,Windows和OS X上的文件浏览器支持哪种URI方案?
嗯,是的,如果没有更好的方法,这必须完成。数据甚至可以从数据库传输到HTTP服务器,因此根本没有等待。如果我完成了,我想我会在我的实施中添加详细的博客帖子。在此之前,我仍然希望有一个更简单的把戏。 –