Miga
5th July 2012, 12:37
Hello!
Win7, Qt 4.8.
I use Model/View based on QStandardItemModel and QTreeView. Some items are not allowed to get dropped items. When I try to drop into them, they don't get the dropped item (as they should), but the source item is removed after the failed drop attempt.
The same situation is described here (http://www.qtcentre.org/threads/47868-Drag-Drop-problem-with-model-views). Is it really a bug?
I tried to reimplement dropMimeData, f.e:
bool TMyModel::dropMimeData(const QMimeData * apData, Qt::DropAction aAction, int aRow, int aColumn, const QModelIndex & aParent)
{
if (/*some condition*/)
return QAbstractItemModel::dropMimeData ( apData, Qt::IgnoreAction, aRow, aColumn, aParent );
return QAbstractItemModel::dropMimeData ( apData, aAction, aRow, aColumn, aParent );
}
or so
bool TMyModel::dropMimeData(const QMimeData * apData, Qt::DropAction aAction, int aRow, int aColumn, const QModelIndex & aParent)
{
if (/*some condition*/)
return false;
return QAbstractItemModel::dropMimeData ( apData, aAction, aRow, aColumn, aParent );
}
RemoveRows is called in all cases and the dragged item disappears. Could I avoid the calling of removeRows?
Thanks for any help.
Win7, Qt 4.8.
I use Model/View based on QStandardItemModel and QTreeView. Some items are not allowed to get dropped items. When I try to drop into them, they don't get the dropped item (as they should), but the source item is removed after the failed drop attempt.
The same situation is described here (http://www.qtcentre.org/threads/47868-Drag-Drop-problem-with-model-views). Is it really a bug?
I tried to reimplement dropMimeData, f.e:
bool TMyModel::dropMimeData(const QMimeData * apData, Qt::DropAction aAction, int aRow, int aColumn, const QModelIndex & aParent)
{
if (/*some condition*/)
return QAbstractItemModel::dropMimeData ( apData, Qt::IgnoreAction, aRow, aColumn, aParent );
return QAbstractItemModel::dropMimeData ( apData, aAction, aRow, aColumn, aParent );
}
or so
bool TMyModel::dropMimeData(const QMimeData * apData, Qt::DropAction aAction, int aRow, int aColumn, const QModelIndex & aParent)
{
if (/*some condition*/)
return false;
return QAbstractItemModel::dropMimeData ( apData, aAction, aRow, aColumn, aParent );
}
RemoveRows is called in all cases and the dragged item disappears. Could I avoid the calling of removeRows?
Thanks for any help.