I'm using the "MultiSelection" mode in a QTreeWidget, so that whenever one clicks on an item, its selection status is toggled and other item's selection is left unchanged.

The problem is that I also want to use drag&drop. If I try dragging a non-selected item, its gets dragged as expected, but when I try dragging an item that was previously selected, QT (instead of dragging) tries to toggle the selection status of all items between were the "drag" started and where the mousepointer is now.

Is there a way to disable this "range select" and have QT start a proper drag even if the item I tried to drag was selected?

Qt Code:
  1. #include <QApplication>
  2. #include <QTreeWidget>
  3.  
  4. int main( int argc, char **argv )
  5. {
  6. QApplication app( argc, argv );
  7. QTreeWidget *tree = new QTreeWidget();
  8. tree->setSelectionMode(QAbstractItemView::MultiSelection);
  9. tree->setDragEnabled(true);
  10. tree->setAcceptDrops(true);
  11. tree->setDropIndicatorShown(true);
  12. tree->setColumnCount(1);
  13. for (int i=1; i<=20; i++) {
  14. QTreeWidgetItem *item = new QTreeWidgetItem(tree);
  15. item->setText(0, QString::number(i));
  16. }
  17. tree->show();
  18.  
  19. return app.exec();
  20. }
To copy to clipboard, switch view to plain text mode