QTableView: fix moving rows by drag-n-drop

If we don't set dropEventMoved to true, then QAbstractItemView::startDrag
will delete the rows after the move (after QDrag::exec() returns).

Fixes: QTBUG-129128
Change-Id: I85e7903a12b13c4b73e34fa1fcac56e50f421191
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
(cherry picked from commit d2384783477e88190fb87287bb9af8ea9a46343e)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
(cherry picked from commit 7f35844ed0beb48ed6ebdab9d56cd832c188cb90)
This commit is contained in:
David Faure 2024-09-19 16:09:21 +02:00 committed by Qt Cherry-pick Bot
parent e8122a0a9c
commit f70e4a49c9

View File

@ -3165,11 +3165,13 @@ void QTableView::dropEvent(QDropEvent *event)
}
r = pIndex.row() + 1; // Dropped items are inserted contiguously and in the right order.
}
if (dataMoved)
if (dataMoved) {
d->dropEventMoved = true;
event->accept();
}
}
}
}
if (!event->isAccepted()) {
// moveRows not implemented, fall back to default