The models viewed by the QListView and QTreeView must agree on a format (more precisely, a MIME type) representing the data being dragged and dropped.
For instance, you could choose the standard text/uri-list MIME type, and represent the files begin dragged as the list of their URLs. QMimeData::setUrls() will let you encode a list of QUrl as MIME data.
Then, follow the documentation that explains how to set up the source and target models and views so that they share this MIME type to drag and drop files:
http://doc.qt.io/qt-4.8/model-view-programming.html#using-drag-and-drop-with-item-views
The source model will need custom implementations of QAbstractItemModel::mimeTypes() and QAbstractItemModel::mimeData(). The target model will need custom implementations of QAbstractItemModel::mimeTypes(), QAbstractItemModel::dropMimeData(), and maybe QAbstractItemModel::canDropMimeData().




Reply With Quote

Bookmarks