Results 1 to 2 of 2

Thread: Dragging to windows (pyqt)

  1. #1
    Join Date
    Sep 2008
    Qt products
    Unix/X11 Windows

    Default Dragging to windows (pyqt)

    I am trying to figure out how to drag items to another windows application. In particular in this case I want to be able to drag items into a winamp playlist.

    For all of this I am using pyqt4.

    To start out with I am using a QDirModel with a QColumnView widget. I have dragging enabled and when I attempt to drag a file the mimeData given for the drag is "text/uri-list" (the default). While explorer can handle this drag, when I try to drag the item into winamp the url shows up in the playlist but it can't do anything with it (it doesn't seem to recognize it as a file).

    How can I get this to work?

    It would seem to me that QWindowsMime might be what I want in order to get a native windows object for the drag, but that does not exist (at least as far as I can see) in pyqt4.

    Is there some other mime type that I can add to drag (by reimplementing mimeData in my QDirModel) that would make winamp understand the drag?

    Another question that is related is that when I drag a file into Qt from windows there is a mime type 'application/x-qt-windows-mime;value="FileName"' in the mimeData object. Does this mime type have any meaning when dragging out of Qt?

    Thanks far any help on this, I am new to pyqt (and windows programming in general) and I am not able to find much help on this stuff on the web.

    - amicitas

  2. #2
    Join Date
    Sep 2008
    Qt products
    Unix/X11 Windows

    Default Re: Dragging to windows (pyqt)

    I was unable to find any solution for this using PyQt.
    So what I did was write a class that does native NT dragging using windows OLE / COM. This was done using pywin32. The documentation for that stuff is pretty scarce (and I still haven't figured out how to find out if the drag was successful).

    I got a bunch of help from the pywin32 mailing list to do this (a big thank you to them).

    To get this into my Qt program I reimplemented "startDrag()". It checks for 'nt' and if it finds it calls my NtDrag class, otherwise it uses the normal qt dragging.

    I don't know if this is the best way to do things, but it does what I need for now.

    If anyone has suggestions on how to do this better let me know.

    I posted the dragging code to that mailing list. Rather than copy it here I will link in case I get anymore help from there.

    [python-win32] Drag and drop of files (CF_HDROP)

    -- amicitas

Similar Threads

  1. Windows not appearing in XP.
    By beardybloke in forum Qt Programming
    Replies: 7
    Last Post: 24th October 2007, 18:32
  2. converting unix exe to windows binary
    By deekayt in forum General Programming
    Replies: 2
    Last Post: 17th September 2006, 02:00
  3. Qt and windows vista
    By munna in forum General Discussion
    Replies: 8
    Last Post: 11th January 2006, 23:33

Tags for this Thread


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.