Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
Qt4 支持拖放操作,我在教程中使用过它们。现在我希望能够将外部元素(文件)拖到 GUI 表单中并基于它执行操作(例如获取完整路径并将其复制到某处)。
我不确定这是否是 Qt 无法做到的限制。有人知道如何使用 Qt 做到这一点吗?只需将文件拖入 GUI...
谢谢,马吕斯
大多数文件管理器使用目标提供拖放数据text/uri-list。
text/uri-list
关于链接教程,首先您需要将小部件设置为接受丢弃text/uri-list数据,然后您可以通过调用来检索 URI event.mimeData().urls()。返回值是 QUrl 对象的列表。
event.mimeData().urls()