[PyQt] QContextMenuEvent on a QTreeWidgetItem
Paul Du Bois
dubois at doublefine.com
Fri Dec 17 10:09:09 GMT 2010
Well, I suppose you would start with
class MainWindow(QMainWindow):
def contextMenuEvent(self, event):
item = self.tree_widget.itemAt(event.globalPos())
# create or fetch a QMenu that relates to your item
menu.exec(event.globalPos())
or you could override the event on the widget itself, if you wanted to
deal with subclassing the widget.
Caveat: I haven't tried exactly this myself, but I do create context
menus this way.
p
From: pyqt-bounces at riverbankcomputing.com
[mailto:pyqt-bounces at riverbankcomputing.com] On Behalf Of Christopher
Evans
Sent: Friday, December 17, 2010 1:41 AM
To: pyqt at riverbankcomputing.com
Subject: [PyQt] QContextMenuEvent on a QTreeWidgetItem
Hi guys,
I have been using pyqt for years at many different jobs and many
different projects, however some things elude me. (I am a self-taught
noob at heart)
I have written many tutorials for the community to help spread
knowledge, but this is one of the many things I myself have never found
a good tutorial on:
I just want to make a simple right click contextual menu on a
treewidgetitem.
Can anyone share a snippet showing this?
Thanks!
--
CE
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.riverbankcomputing.com/pipermail/pyqt/attachments/20101217/2ed34670/attachment-0001.html>
More information about the PyQt
mailing list