Set QDirModel::setReadOnly(false) and reimplement QDirModel::flags() to return Qt::ItemIsDropEnabled:
{
public:
AdvQDirModel
(): QDirModel() { setReadOnly
(false);
} // <--- ~AdvQDirModel() { }
Qt::ItemFlags flags(const QModelIndex& index) const
{
if (isDir(index))
f |= Qt::ItemIsDropEnabled; // <---
return f;
}
};
class AdvQDirModel: public QDirModel
{
public:
AdvQDirModel(): QDirModel() { setReadOnly(false); } // <---
~AdvQDirModel() { }
Qt::ItemFlags flags(const QModelIndex& index) const
{
Qt::ItemFlags f = QDirModel::flags(index);
if (isDir(index))
f |= Qt::ItemIsDropEnabled; // <---
return f;
}
};
To copy to clipboard, switch view to plain text mode
EDIT: Actually, now that I relook at it, all you need is to set QDirModel::setReadOnly(false) and that's all. You don't even need to reimplement flags(). The default implementation will enable dropping once read only property is set to false and the dropping target is a writable directory. 
model.setReadOnly(false);
...
listView.setModel(&model);
QDirModel model;
model.setReadOnly(false);
QListView listView;
...
listView.setModel(&model);
To copy to clipboard, switch view to plain text mode
Bookmarks