[Interest] How to reorder QListView contents through Drag-N-Drop

113 views
Skip to first unread message

Michael Jackson

unread,
Apr 3, 2012, 1:03:23 PM4/3/12
to inte...@qt-project.org
I have a QListView in my GUI. I would like to be able to use Drag-N-Drop to allow the user to move items with the list. I have checked some settings in QDesigner to enable this functionality but the issue I am having is that if the user drags a selection directly over another entry then the entry that got dropped on is removed and the selected item that was being dragged is put in its place. Is there a way (without subclassing a custom Model) to disable the dropping of one item on another?
I am currently using a QStringListModel and it looks I need to subclass that model and implement the flags() method?


Qt::ItemFlags DragDropListModel::flags(const QModelIndex &index) const
{
Qt::ItemFlags defaultFlags = QStringListModel::flags(index);

if (index.isValid())
return Qt::ItemIsDragEnabled | defaultFlags;
else
return Qt::ItemIsDropEnabled | defaultFlags;
}

Is this a correct understanding of the situation?


Thanks
Mike Jackson
_______________________________________________
Interest mailing list
Inte...@qt-project.org
http://lists.qt-project.org/mailman/listinfo/interest

Reply all
Reply to author
Forward
0 new messages