[PyKDE] Re: File Drag n drop

Lukáš Lalinský lalinsky at gmail.com
Wed Jan 10 09:37:54 GMT 2007


Tony Cappellini  wrote / napísal(a):
> After looking through the examples & demos,  I don't see an example of what
> I'm looking for.
> 
> I would like to be able to drag a file or files onto a Python QT app, and
> have the app process the file(s).
> 
> The Draggable Icons example isn't quite the same. I want to drag a file
> from
> outside of the application, onto the running application.
> 
> Does anyone know where I can find an example to do this?

Dragging a file from outside of the application is not different than internal
drag&drop. Just setup the widget to accept drops and accept data with MIME type
"text/uri-list" in the handler. Probably the easiest way is to use methods
hasUrls and urls. QMimeData::urls returns a list of QUrl instances, use
toLocalFile to convert the URL to a local file name.

http://doc.trolltech.com/4.2/dnd.html#dropping
http://doc.trolltech.com/4.1/model-view-dnd.html#inserting-dropped-data-into-a-model




More information about the PyQt mailing list