PDA

View Full Version : how to disable OnItem drops in a QListView?



rgl
31st January 2009, 13:54
I'm trying to implement manual sorting of a list of items inside a QListView widget by using drag&drop. I've set dragDropModel to InternalMove and it almost works, expect when I drop an item over another; that will replace the hovered item instead of inserting it between two items. Is there a way to disable this?

I can see there is a QAbstractItemView::DropIndicatorPosition that can take the values:

QAbstractItemView::AboveItem

QAbstractItemView::BelowItem

QAbstractItemView::OnItem

QAbstractItemView::OnViewport

I guess I want to disable the OnItem one, though, how?

wysota
31st January 2009, 14:37
Make sure QAbstractItemModel::flags() doesn't return ItemIsDropEnabled for valid model indexes.

rgl
31st January 2009, 15:26
Make sure QAbstractItemModel::flags() doesn't return ItemIsDropEnabled for valid model indexes.

That was it. Thank you!