QListWidget drag and drop items disappearing from list
- by ppalasek
Hello,
I'm having trouble implementing a QListWidget with custom items that can be reordered by dragging and dropping. The problem is when I make a fast double click (a very short drag&drop) on an item, the item sometimes disappears from the QListWidget.
This is the constructor for my Widget:
ListPopisiDragDrop::ListPopisiDragDrop(QWidget *parent) :
QListWidget(parent)
{
setSelectionMode(QAbstractItemView::SingleSelection);
setDragEnabled(true);
viewport()->setAcceptDrops(true);
setDefaultDropAction(Qt::MoveAction);
setDropIndicatorShown(true);
setDragDropMode(QAbstractItemView::InternalMove);
}
also the drop event:
void ListPopisiDragDrop::dropEvent(QDropEvent *event){
int startRow=currentIndex().row();
QListWidget::dropEvent(event);
int endRow=currentIndex().row();
//more code...
}
Custom items are made by implementing paint() and sizeHint() functions from QAbstractItemDelegate.
When the problem with disappearing items happens, the dropEvent isn't even called.
I really don't know what is happening and if I'm doing something wrong. Any help is appreciated.
Thanks!
Edit:
I'm running the application on a Symbian S60 5th edition phone.
Edit2:
If I add this line to the constructor:
setDragDropOverwriteMode(true);
the item in the list still disappears, but an empty row stays in it's place.