[Qt-interest] How do I have a context menu associated with QTreeWidgetItem
kent williams
nkwmailinglists at gmail.com
Wed Feb 17 23:25:26 CET 2010
I think the basic answer is "U R DOING IT RONG" but here goes...
I want a context menu to pop up when I right click on an item in a QTreeWidget.
According to "C++ GUI Programming with QT 4":
"A more sophisticated way of providing context menus is to reimplement
the QWidget::contextMenuEvent() function, create a QMenu widget,
populate it with desired actions, and call exec() on it."
The problem I'm having is that QTreeWidgetItem doesn't derive from
QWidget, so i can derive a subclass from QTreeWidgetItem, so I can't
re-implement the contextMenuEvent.
QTreeWidgetItem also doesn't derive from QObject, so I can't use
connect on it either.
So what's the proper way to do this? I suppose I have no choice but to
redefine the contextMenuEvent for the whole QTreeWidget, but that
means pushing a whole load of book-keeping from the Leaf
QTreeWidgetItems up to the tree.
More information about the Qt-interest-old
mailing list