Hello
Im facing a little problem regarding QTreeView and drag&drop.
I want to restrict drop only in between the items. I found a good working suggestion on forum so this was not a big deal.
The problem is that i want to restrict items being dropped into different columns, lets say i have file, size and date column and i dont want the file item end up in the date or size column.
right now im using this inherited model class based on the suggestion i mentioned before.
{
public:
{
}
Qt::ItemFlags flags(const QModelIndex& inIndex) const
{
if(!inIndex.isValid() )
return Qt::ItemIsDropEnabled;
return Qt::ItemIsDragEnabled | Qt::ItemIsSelectable | Qt::ItemIsEnabled ;
}
};
class Model : public QStandardItemModel
{
public:
Model(int rows, int cols, QObject* parent = 0) : QStandardItemModel(rows, cols, parent)
{
}
Qt::ItemFlags flags(const QModelIndex& inIndex) const
{
if(!inIndex.isValid() )
return Qt::ItemIsDropEnabled;
return Qt::ItemIsDragEnabled | Qt::ItemIsSelectable | Qt::ItemIsEnabled ;
}
};
To copy to clipboard, switch view to plain text mode
Is there a way to do this without completely new customized QTreeView?
Or maybe is there better component for this particular purpose than QTreeView?
thanks a lot!
Bookmarks