问题
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