我有一个 QListView 并想要实现拖放以让用户将列表中的项目移动到他/她想要的顺序。我的代码摘录是
ui.lstViewBodyFiles->setDragEnabled(true);
ui.lstViewBodyFiles->setDropIndicatorShown(true);
ui.lstViewBodyFiles->setAcceptDrops(true);
ui.lstViewBodyFiles->setSelectionMode( QAbstractItemView::SingleSelection);
ui.lstViewBodyFiles->setDragDropMode( QAbstractItemView::InternalMove);
Run Code Online (Sandbox Code Playgroud)
上面的代码删除了这些项目而不是在内部移动它们。
Windows 10 上的 Qt 5.3.2。