Unsolved How to move items in a qtreewidget?
-
I wonder if someone could show me an example how to move qtreewidgetitems in a qtreewidget?
I would like to move an item, and all its sub items, to a new place in the tree. I guess that could be triggered by drawing the item with the mouse.
-
Take a look at the example here
basically you nee to subclass the model and then implement
flags() as well as mimeData() and dropMimeData() -
QTreeWidget is already implemented to drag & drop.
You can just enable that bysetDragDropMode(QAbstractItemView::InternalMove)
.
After that all the items with Qt::ItemIsDragEnabled / Qt::ItemIsDropEnabled flag will be able to be dragged / dropped.
But it is not well controlled. For example, you cannot limit a item to be moved to only the same level. -
But how can I find out what item was dragged and on what item it was dropped?
-
Hi,
Why do you need that information for ?