Copying file(s) with drag and drop from Qt 5.2 application to file system

和自甴很熟 提交于 2019-12-10 21:54:40

问题


How do I go about generating a file drag and drop operation in a Qt 5.2 application that performs a copy (or move) in the file system (Windows, Mac, etc.)? More specifically: Generate a drag with 1+ file paths that will perform a copy/move on those files when dropped onto the system.

Is there a standard mime-type I can use for this - providing file paths as mime data?


回答1:


QMimeData has a functionality to add a text/uri-list.

To drag/drop a file onto the system add a QUrl that starts with file:/// followed by your path.

QList<QUrl> urls;

list.append(QUrl("file:///path");

QMimeData* mimeData = new QMimeData;

mimeData->setUrls(list);


来源:https://stackoverflow.com/questions/23839932/copying-files-with-drag-and-drop-from-qt-5-2-application-to-file-system

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!