QT right click menu
overwrite your widget’s method contextMenuEvent
make a menu in init of the main widget
add this to a childwidget
# create context menu when right c lick
def contextMenuEvent(self, event):
widget = self.childAt(event.pos())
menu = widget.parentWidget().menu
action = menu.exec_(self.mapToGlobal(event.pos()))
if only using 1 widget just forgo the parent code
use addAction
to add menu entries
Question
how to pass the widget to menu.exec
?
a workaround is to save widget in self.last_widget