PDA

View Full Version : Get target Object for drag and drop in QTreeWidget



ng2b30
14th June 2019, 12:34
I am currently working on dragging a treeWidgetItem to two different treeWidgets. Is there any way to let me get target treeWidget in dragMoveEvent(QDragMoveEvent *event) or other function when I am dragging a treeWidgetItem so that I can some animation effect to the target TreeWidget?

Also, can I get the itemIndex for the position of my mouse when I am dragging the item to another TreeWidget? Thank you very much.

anda_skoa
14th June 2019, 15:20
Not quite sure I understand you first question.

The "dragMoveEvent" handler is in your target class, no?

As for position: the event object has a position and the view has an indexAt() method.

Cheers,
_

ng2b30
15th June 2019, 03:16
Not quite sure I understand you first question.

The "dragMoveEvent" handler is in your target class, no?

As for position: the event object has a position and the view has an indexAt() method.

Cheers,
_

The "dragMoveEvent" handler can be my target class but I can also use other class. Any suggestion?

Is there any way to directly get the target treeWidgetitem instead of comparing their position? Thank you.