Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Drag & drop from/to desktop or folder in Windows or Linux
Forum Updated to NodeBB v4.3 + New Features

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

Scheduled Pinned Locked Moved General and Desktop
2 Posts 1 Posters 3.3k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • C Offline
    C Offline
    ChanchoCiego
    wrote on last edited by
    #1

    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:

    @
    BEGIN_MESSAGE_MAP
    MESSAGE_HANDLER(WM_DROPFILES, TWMDropFiles, WmDropFiles)
    END_MESSAGE_MAP( TForm )
    @

    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 );
    }
    DragFinish(hDrop);

    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.

    So:

    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.

    Darío-

    [[merged two identical posts, Tobias]]

    1 Reply Last reply
    0
    • C Offline
      C Offline
      ChanchoCiego
      wrote on last edited by
      #2

      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: "http://qt-project.org/doc/qt-4.8/dnd.html":http://qt-project.org/doc/qt-4.8/dnd.html

      Best regards.

      1 Reply Last reply
      0

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved