Stopping dragged item dropping on top of other item
I've set up a tree view which lists my items. I can drag and drop items in the view, however if I drop an item on top of an other it becomes a "branch" of that item. Basically if I have the below list abd move item 2 ontop of 3 it becomes part of it so
move 2 and accidentally drop on item 3 rather than in gap ( difficult to show because of formatting )
..................|--- item 2
How can I set it up do if I drop on an other item it moves above or below it? I can see this enum "QAbstractItemView::BelowItem" but if this is the solution I don't know how to use it? Thanks! My set up is below
ui->treeView_2->setModel( ListItem.get_tree_model( ) ); ui->treeView_2->setDropIndicatorShown( true ); ui->treeView_2->setDragEnabled( true ); ui->treeView_2->setSelectionBehavior( QAbstractItemView::SelectRows ); ui->treeView_2->setDragDropMode(QAbstractItemView::InternalMove);
You have to re-implement the drop handling of QTreeView if you want to avoid that.
If you want to have only a one column view, then why not use QListView ?