Items after dropping from widget to widget missing
Unsolved
General and Desktop
-
After dragging and dropping an item from a list widget to a list widget, the item disappears in the target list widget.
I used eventFilter for only the list widgets in MainWindow.
bool MainWindow::eventFilter(QObject *target,QEvent *event){ if (event->type() == QEvent::DragEnter) { QDragEnterEvent *tDragEnterEvent = static_cast<QDragEnterEvent *>(event); tDragEnterEvent->acceptProposedAction(); return true; } else if (event->type() == QEvent::DragMove) { QDragMoveEvent *tDragMoveEvent = static_cast<QDragMoveEvent *>(event); tDragMoveEvent->acceptProposedAction(); return true; } else if (event->type() == QEvent::Drop) { QDropEvent *tDropEvent = static_cast<QDropEvent *>(event); tDropEvent->acceptProposedAction(); qDebug() << "OK, execute your task!"; return true; } else { // standard event processing return QObject::eventFilter(target, event); } //return false; } //in MainWindow constructor ui->listWidget->installEventFilter(this);
qDebug showed the debug string after dropping but the item went missing.
-
You filter out the drop events and the wonder why the widget which should receive them don't receive them? Mhh.
-
See documentation for QObject::eventFilter(): "... if you want to filter the event out, i.e. stop it being handled further, return true; ..." which is exactly what you're doing.
-
Drag'n'Drop from a QListWidget to another QListWidget should work out-of-the-box if dragEnabled/acceptDrops is active - see documentation