gpt4 book ai didi

qt - 将文件从应用程序拖到资源管理器。我的应用程序可以复制吗?

转载 作者:行者123 更新时间:2023-12-03 17:42:24 24 4
gpt4 key购买 nike

在 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 使用,而是存储在数据库中。我无法快速存储到 temp,因为这可能需要几秒钟,而且用户不希望在他开始拖动的那一刻延迟。

是否有可能在删除后获取目标 URI 并自己进行复制?还是只有目标才能复制?

在后一种情况下,我是否需要通过内部 HTTP 服务器使我的数据可用?我怎么知道 Linux、Windows 和 OS X 上的文件浏览器支持哪种 URI 方案?

最佳答案

我会使用类似的东西:

Drag.mimeData: { "text/uri-list": "http://localhost:8080/datarepository?id=12345" }

然后我将在应用程序内 HTTP 服务器上提供请求的数据(然后可以轻松地从 DB 中提取 ID 等于 12345 的对象)...(一旦复制操作开始,我不如果您的用户在系统从数据库中提取对象时等待几秒钟,请不要认为这是一种耻辱)。

关于qt - 将文件从应用程序拖到资源管理器。我的应用程序可以复制吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33174044/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com