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. How to Drag & Drop from QFileSystemModel QTreeView to Custom QTreeView
Forum Updated to NodeBB v4.3 + New Features

How to Drag & Drop from QFileSystemModel QTreeView to Custom QTreeView

Scheduled Pinned Locked Moved Unsolved General and Desktop
2 Posts 2 Posters 1.7k 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.
  • P Offline
    P Offline
    pvt.peter
    wrote on last edited by
    #1

    Hi Everybody,

    I have got a custom QTreeView which represents a folder structure with feature of internal drag & drop (based on Full drag and drop support in QTreeView).
    I have got an other QTreeView which has got a QFileSystemModel model.
    I would like to implement drag from QFileSystemModel QTreeView to Custom QTreeView.
    It is only a one-way "channel", so i don't want to drag an item from Custom QTreeView to QFileSystemModel QTreeView.

    Further informations:

    • acceptDrops property is true both of them
    • showDropIndicator property is true both of them
    • dragEnabled property is true both of them
    • dragDropMode property is CopyAction both of them

    Custom QTreeView's model has got the next overridden methods:

    Qt::DropActions TreeModel::supportedDropActions() const
    {
       return Qt::MoveAction;
    }
    
    Qt::DropActions TreeModel::supportedDragActions() const
    {
       return Qt::MoveAction;
    }
    Qt::ItemFlags TreeModel::flags(const QModelIndex &index) const
    {
       if (!index.isValid())
       {
          return Qt::ItemIsDropEnabled;
       }
       return QAbstractItemModel::flags(index) | Qt::ItemIsDragEnabled | Qt::ItemIsDropEnabled;
    }
    

    How can i drag(copy) an item from QFileSystemModel QTreeView to Custom QTreeView?

    BR,
    Peter

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

      Take a look at the drag and drop part of the model view programming chapter in Qt's documentation.

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      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