Results 1 to 3 of 3

Thread: How can I drag a file out of a TreeView and into another application?

  1. #1
    Join Date
    Jun 2021
    Posts
    2
    Qt products
    Qt5
    Platforms
    MacOS X Windows

    Question How can I drag a file out of a TreeView and into another application?

    I have a Treeview with QStandardItems. Each item has a path url to a local audio file and I am not sure how to add the ability to drag on of those items into another app like VLC.

    I am subclassing the TreeView class and overriding these methods

    //Mouse press event, start drag event
    void mousePressEvent(QMouseEvent* event) override;

    // //drag operation in the form move event
    void dragMoveEvent(QDragMoveEvent* event) override;

    // //drag operation enters the form
    void dragEnterEvent(QDragEnterEvent* event) override;
    void dragLeaveEvent(QDragLeaveEvent* event) override;

    // //drop release event
    void dropEvent(QDropEvent* event) override;

    Still whenever I drag out an Item is is disabled

  2. #2
    Join Date
    Jul 2008
    Location
    Germany
    Posts
    474
    Thanks
    10
    Thanked 62 Times in 60 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: How can I drag a file out of a TreeView and into another application?

    Hi, please show us how you create your QDrag object.

    Ginsengelf

  3. #3
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    5,018
    Thanks
    280
    Thanked 816 Times in 805 Posts
    Qt products
    Qt5
    Platforms
    Windows Android

    Default Re: How can I drag a file out of a TreeView and into another application?

    Still whenever I drag out an Item is is disabled
    If you do not create your QDrag object with QMimeData of the correct MIME type for VLC (or whatever the other app expects), then the other app will not accept it. So as Ginsengelf says:

    please show us how you create your QDrag object.
    <=== The Great Pumpkin says ===>
    Please use CODE tags when posting source code so it is more readable. Click "Go Advanced" and then the "#" icon to insert the tags. Paste your code between them.

Similar Threads

  1. Treeview + edit item (and drag and drop)
    By JanW in forum Qt Quick
    Replies: 0
    Last Post: 24th August 2016, 13:31
  2. Replies: 2
    Last Post: 16th June 2016, 11:19
  3. Replies: 0
    Last Post: 29th July 2015, 08:34
  4. Drag n Drop with multiple TreeView
    By laugusti in forum Qt Programming
    Replies: 0
    Last Post: 6th October 2009, 16:14
  5. Drag and drop outside the application
    By jpn in forum Newbie
    Replies: 7
    Last Post: 27th August 2006, 15:37

Tags for this Thread

Bookmarks

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.