Do you mean that your dropMimeData() implementation doesn't get called at all? Then there must be something wrong because QDirModel surely does the dropping work in dropMimeData().
Btw, your flags() shouldn't be necessary. QDirModel already adds Qt::ItemIsDropEnabled where appropriate:
{
if (!d->indexValid(index))
return flags;
flags |= Qt::ItemIsDragEnabled;
if (d->readOnly)
return flags;
QDirModelPrivate::QDirNode *node = d->node(index);
if ((index.column() == 0) && node->info.isWritable()) {
flags |= Qt::ItemIsEditable;
if (fileInfo(index).isDir()) // is directory and is editable
flags |= Qt::ItemIsDropEnabled; // <---
}
return flags;
}
Qt::ItemFlags QDirModel::flags(const QModelIndex &index) const
{
Q_D(const QDirModel);
Qt::ItemFlags flags = QAbstractItemModel::flags(index);
if (!d->indexValid(index))
return flags;
flags |= Qt::ItemIsDragEnabled;
if (d->readOnly)
return flags;
QDirModelPrivate::QDirNode *node = d->node(index);
if ((index.column() == 0) && node->info.isWritable()) {
flags |= Qt::ItemIsEditable;
if (fileInfo(index).isDir()) // is directory and is editable
flags |= Qt::ItemIsDropEnabled; // <---
}
return flags;
}
To copy to clipboard, switch view to plain text mode
Bookmarks