How to implement a drag'n drop from a qt application to a file system folder?

[亡魂溺海] 提交于 2019-12-24 03:07:30

问题


I'm developing a Qt application on Mac OS X (Snow Leopard), which displays the datas of a big file into a view. I can extract theses data onto a file system folder with an entry "extract" of a menu and, now, I would like extract them with a drag'n drop.

I tried to implement a custom QMimeData, and its protected method retrieveData like the solution of this ticket: Qt 4.x: how to implement drag-and-drop onto the desktop or into a folder?). In this method, I extract the data into a tmp folder and I return the path of the tmp file. Unhappily, this method is called at the beginning of the drag'n drop and extracts my data at this moment (even if the user doesn't drop this data).

How do you do a drag'n drop to a file system folder on Mac OS X, with Qt?


回答1:


That's one glaring issue in Qt's drag and drop scheme: it doesn't provide the equivalent of OS X's "promised data" drag. And there's really no good way to work around it. The dragging code is not informed of where the drop is, so there's no way to copy the data after the fact. And as you've found out, retrieve data is called right at the moment the drag starts, which doesn't help when it takes a long time to prepare the data.

Right now I'd say hacking it with platform specific code is the only way to do it. Unfortunately, I don't have any experience on that.



来源:https://stackoverflow.com/questions/5854546/how-to-implement-a-dragn-drop-from-a-qt-application-to-a-file-system-folder

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