How can I show a context menu when right clicking on QTreeWidgetItem?
I have a QTreeWidget, which is populated with QTreeWidgetItems. How do I setup a handler so that when a user right clicks on each tree item, different context menus can be shown?
Many thanks, I tried a few things like the contextMenuPolicy but that only appears to work on the QTreeWidget itself, not its actual items.
Re: How can I show a context menu when right clicking on QTreeWidgetItem?
override contextEvent() and feed the pos() of the event to the QTreeWidget's itemAt() to find out which tree item you right-clicked.
Re: How can I show a context menu when right clicking on QTreeWidgetItem?
Quote:
Originally Posted by
drhex
override contextEvent() and feed the pos() of the event to the QTreeWidget's itemAt() to find out which tree item you right-clicked.
This doesn't work because the event doesn't get fired when right clicking on a tree item, only when right clicking on the header of the tree widget.
Re: How can I show a context menu when right clicking on QTreeWidgetItem?
Any other suggestions on this? There must be an easy way to do this no? I can't imagine nobody is showing right click context sensitive menus in QT apps.
Re: How can I show a context menu when right clicking on QTreeWidgetItem?