Important: Please read the Qt Code of Conduct -

Drag & drop from/to desktop or folder in Windows or Linux

  • Hello, good afternoon,

    (sorry for my English of bing translator)

    I'm starting to migrate to Qt from Borland C ++ Builder, the last version I used is the XE, and I regret having taken so much time to migrate, Qt seems a lot simpler and faster to work that BCB.

    Like all beginner in this IDE and the Qt libraries, I am with some problems for which I ask to help me.

    I have an application with a QTreeWidget and a QListWidget, and each widget must be able to accept lists of files dragged from a Windows folder (desktop as folder or any other folder) or Linux and should also be able to drag lists of items and drop them into a folder.

    In BCB (Windows) I did it this way:

    On the header of the form's class, he placed these "capture" in the public section:


    and I implemented them as well:

    void __fastcall TfrmBandeja::WmDropFiles(TWMDropFiles& Message)
    wchar_t buff[MAX_PATH];
    HDROP hDrop = (HDROP)Message.Drop;
    int numFiles = DragQueryFile(hDrop, -1, NULL, NULL);
    // PRUEBA
    TStringList* lst = new TStringList;

    for (int i=0;i < numFiles;i++)

    DragQueryFile(hDrop, i, buff, sizeof(buff));

    // process the file in 'buff'

    lst->Add( buff );

    expandirDirectorios( lst );

    FEvArchivosIngresados( (TObject*)this, (TStringList*)lst ); // disparador del evento

    I use Qt compiled with VC2010, then I guess that, in Windows not must be complicated to implement it. By the side of Linux, if I drag a file from or to the desktop, will depend on the desktop that I use, but if I drag a folder or from, I guess that the implementation should be quite specific Qt.


    If you would like I can implement the capture of these events in Qt?

    In addition:

    As I drag the Widget items (which are files) and drop them into a folder?

    Thank you very much from now with all help or guide that I can give.

    Best regards.


    [[merged two identical posts, Tobias]]

  • Sorry for asking a question about a fully documented topic.

    I assumed that the documented Drag and Drop was for operations between widgets of the same application. They are remnants of BCB.

    Full documentation: "":

    Best regards.

Log in to reply