View Full Version : How can I show a context menu when right clicking on QTreeWidgetItem?
Joachie
12th April 2009, 17:05
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.
drhex
12th April 2009, 20:32
override contextEvent() and feed the pos() of the event to the QTreeWidget's itemAt() to find out which tree item you right-clicked.
Joachie
12th April 2009, 23:53
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.
Joachie
13th April 2009, 19:34
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.
spirit
13th April 2009, 19:37
read this (http://www.qtcentre.org/forum/p-qtreewidgetitem-have-contextmenu--post93472/postcount3.html).
Powered by vBulletin® Version 4.2.5 Copyright © 2024 vBulletin Solutions Inc. All rights reserved.