Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Solved Drag&Drop using QFileSystemModel.

    General and Desktop
    qfilesystemmode qtableview drag and drop qabstractitemvi
    2
    4
    1743
    Loading More Posts
    • 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.
    • T
      tokafr last edited by

      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?

      1 Reply Last reply Reply Quote 0
      • mrjj
        mrjj Lifetime Qt Champion last edited by

        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

        T 1 Reply Last reply Reply Quote 1
        • T
          tokafr @mrjj last edited by

          @mrjj
          Thank you that is ok now.

          mrjj 1 Reply Last reply Reply Quote 1
          • mrjj
            mrjj Lifetime Qt Champion @tokafr last edited by

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

            1 Reply Last reply Reply Quote 0
            • First post
              Last post