Drag&Drop using QFileSystemModel.



  • Hello
    I have a widget containing 2 QTableView. each has QFileSystemModel object as model.
    I want to have a possibility of copying files from one view to another using drag&drop.
    I have set this for both views:

    tableView_ -> setDragEnabled(true);
    tableView_ -> setAcceptDrops(true);
    tableView_ -> setDropIndicatorShown(true);
    

    then I reimplemented those methods(Do I really need it?):
    void dropEvent(QDropEvent *event);
    void dragMoveEvent(QDragMoveEvent *event);
    void dragEnterEvent(QDragEnterEvent *event);

    items on the view are dragging ok but when i drop it it doesn't copy anything and does nothing. how can I use QFileSystemModel D&D then I have QTableView. What I have to do?


  • Qt Champions 2017

    Hi
    Have you tried to set
    readOnly
    to false. Doc says its default
    true.
    http://doc.qt.io/qt-5/qfilesystemmodel.html#readOnly-prop

    I dont think you need to implement dropXXX



  • @mrjj
    Thank you that is ok now.


  • Qt Champions 2017

    @tokafr
    Super.
    so it can copy files on its own ?
    Doc hinted it, but I was not sure.



Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.