QTreeWidget.itemAt returns wrong item in dropEvent
-
wrote on 15 Oct 2024, 10:41 last edited by
Hello,
Code in QTreeWidget dropEvent:
targetItem = self.targetTree.itemAt(event.position().x(), event.position().y())
the item returned is consistently 4 rows under the correct one. Why is that?
TIA
-
Hello,
Code in QTreeWidget dropEvent:
targetItem = self.targetTree.itemAt(event.position().x(), event.position().y())
the item returned is consistently 4 rows under the correct one. Why is that?
TIA
wrote on 15 Oct 2024, 13:37 last edited by Pl45m4@ForeverNoob said in QTreeWidget.itemAt returns wrong item in dropEvent:
Why is that?
It can only be for one reason:
event.position().x(), event.position().y()
these coords are not what you would expect.
The documentation says:
item at the coordinates (x, y). The coordinates are relative to the tree widget's viewport().
So compare that with the position of your correct item
-
@ForeverNoob said in QTreeWidget.itemAt returns wrong item in dropEvent:
Why is that?
It can only be for one reason:
event.position().x(), event.position().y()
these coords are not what you would expect.
The documentation says:
item at the coordinates (x, y). The coordinates are relative to the tree widget's viewport().
So compare that with the position of your correct item
wrote on 16 Oct 2024, 11:32 last edited by@Pl45m4 Sorry, I was working with the wrong dropEvent. Me stupid. Things work now.
Thanks
-
3/3