View Full Version : Drag vs range-select

19th February 2006, 21:39
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?

#include <QApplication>
#include <QTreeWidget>

int main( int argc, char **argv )
QApplication app( argc, argv );
QTreeWidget *tree = new QTreeWidget();
tree->setSelectionMode(QAbstractItemView::MultiSelection );
for (int i=1; i<=20; i++) {
QTreeWidgetItem *item = new QTreeWidgetItem(tree);
item->setText(0, QString::number(i));

return app.exec();