Qt Drag and Drop to windows explorer: How do I know the dropped destination path(Qt拖放到Windows资源管理器:我如何知道放置的目标路径)
问题描述
我要做的是显示在线文件的列表视图,就像 FTP 客户端列出 FTP 服务器上的所有文件一样,可以将任意一行或多行拖动到任何本地文件夹以保存拖动的文件在那里.
What I'm trying to do is to display a listview of online files, just like an FTP client lists all the files on the FTP server, and one can drag any row or rows to any local folder to save the dragged files right there.
我计划通过以下步骤来实现:
I'm planning to implement this through the follwing steps:
- 初始化拖拽事件,并将选中文件的路径保存到服务器[完成]
- 子类 QMimeData 类,并覆盖retrieveData 函数,就像这个线程建议的那样这里 [完成]
- 只需完成拖放过程,然后找到拖放的目标路径,例如 C:somefoldersubfolder,然后将所有文件下载到那里,就完成了.【未完成】
- init the drag event, and save the selected files' path on the server [done]
- subclass QMimeData class, and overwrite retrieveData function just as this thread suggests here [done]
- Just finish the drag and drop process, and find the dropped destination path, say C:somefoldersubfolder, then download all the files there, job done. 【not done】
但我无法找到任何地方来获取放置的目标路径,甚至无法通过处理 dragEnterdragMovedragLeavedrop 事件.我也进行了大量的谷歌搜索,发现了一些类似的问题,但从来没有任何可靠的答案.
But I could not find anywhere to get the dropped destionation path, not even by processing dragEnterdragMovedragLeavedrop events. I've also done tons of google search, found some similar questions but never any solid answer.
请对此有所了解.这种解决方案甚至可以与 QT 一起使用吗?我应该如何获得目标路径或者有没有其他方法可以实现这个目标?
Please shed some light on this. Is this solutuion even doable with QT ? How should I get the destination path or is there any other way to achieve this goal ?
推荐答案
对于任何正在寻找这个的人,我可能会找到答案,但这并不容易,并且可能取决于平台.
For anyone who's searching for this, I might find an answer, but it ain't easy and could be platform dependent.
经过大量(字面意思)搜索,我在 FileZilla's 源代码中找到了解决方案,结果证明可以应付在这种情况下,您需要:
After tons of (literally) search, I found a solution in FileZilla's source code, turns out to cope with such situatuation, you need:
- 您需要一个 shell 扩展来监控(或其他)拖动过程
- 开始正常的拖放操作
- 当鼠标落下时,什么都不做,让整个拖放过程结束
- 通过 shell 扩展,您可以获得实际的目标路径,然后将文件下载到那里.
技术细节请访问FileZilla官网
我认为这仅适用于Windows,如果有人得到其他平台的答案,请告诉我!
I think this is for windows only, if anyone get the answer for other platforms, please let me know!
这篇关于Qt拖放到Windows资源管理器:我如何知道放置的目标路径的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:Qt拖放到Windows资源管理器:我如何知道放置的目标路径
基础教程推荐
- 如何将 std::pair 的排序 std::list 转换为 std::map 2022-01-01
- 如何检查GTK+3.0中的小部件类型? 2022-11-30
- 静态库、静态链接动态库和动态链接动态库的 .lib 文件里面是什么? 2021-01-01
- 如何通过C程序打开命令提示符Cmd 2022-12-09
- 这个宏可以转换成函数吗? 2022-01-01
- 在 C++ 中计算滚动/移动平均值 2021-01-01
- 常量变量在标题中不起作用 2021-01-01
- 我有静态或动态 boost 库吗? 2021-01-01
- 如何在 C++ 中初始化静态常量成员? 2022-01-01
- C++结构和函数声明。为什么它不能编译? 2022-11-07
