开发者

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

开发者 https://www.devze.com 2023-03-02 07:08 出处:网络
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 \"e开发者_JAVA技巧xtr

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 "e开发者_JAVA技巧xtract" 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?


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消