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 using QFileSystemModel.
QtWS25 Last Chance

Drag&Drop using QFileSystemModel.

Scheduled Pinned Locked Moved Solved General and Desktop
qfilesystemmodeqtableviewdrag and dropqabstractitemvi
4 Posts 2 Posters 2.3k Views
  • 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 Offline
    T Offline
    tokafr
    wrote on 13 Apr 2016, 10:29 last edited by
    #1

    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
    0
    • M Offline
      M Offline
      mrjj
      Lifetime Qt Champion
      wrote on 13 Apr 2016, 10:48 last edited by
      #2

      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 13 Apr 2016, 10:57
      1
      • M mrjj
        13 Apr 2016, 10:48

        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 Offline
        T Offline
        tokafr
        wrote on 13 Apr 2016, 10:57 last edited by
        #3

        @mrjj
        Thank you that is ok now.

        M 1 Reply Last reply 13 Apr 2016, 10:58
        1
        • T tokafr
          13 Apr 2016, 10:57

          @mrjj
          Thank you that is ok now.

          M Offline
          M Offline
          mrjj
          Lifetime Qt Champion
          wrote on 13 Apr 2016, 10:58 last edited by
          #4

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

          1 Reply Last reply
          0

          4/4

          13 Apr 2016, 10:58

          • Login

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