View Full Version : Drag and Drop on Whitespace of QTreeView
T1c4L
14th May 2008, 11:14
Hi everybody,
I read the Drag and Drop with Item views tutorial but somehow, drag drop is only working when im droping on an existing item within the treeview.
How do I drop items on the empty area within a treeview?
thx in advance,
Mike
janus
14th May 2008, 11:29
take a look at the function where the dropaction is accepted. Their must be something e.g. that makes the invisible parent item rejecting drops (or something similar).
T1c4L
14th May 2008, 11:37
hmm it looks like this:
Qt::DropActions CLTLectionModel::supportedDropActions() const
{
return Qt::CopyAction | Qt::MoveAction;
}
T1c4L
14th May 2008, 13:25
how do i drop on the top level of my treeview? do i have to edit my custom model?
Reimplement QAbstractItemModel::flags() to return Qt::ItemIsDropEnabled (together with other flags) for invalid indexes.
T1c4L
14th May 2008, 14:10
Hi jpn,
my flags already contain such flags. Do you have any other idea?
Qt::ItemFlags CLTLectionModel::flags(const QModelIndex &index) const
{
if (!index.isValid())
return Qt::ItemIsEnabled;
return QAbstractItemModel::flags(index) | Qt::ItemIsEditable | Qt::ItemIsDragEnabled | Qt::ItemIsDropEnabled;
}
I think Qt::ItemIsEnabled for invalid items is pointless. Also, you are not returning Qt::ItemIsDropEnabled for invalid items..
Powered by vBulletin® Version 4.2.5 Copyright © 2024 vBulletin Solutions Inc. All rights reserved.