Context menus: trigger an action on an item that has a sub-menu.
-
Hi Everyone,
I am building context menus with submenus - and I can trigger an action on the submenu. But I would also like to trigger an action on the item that has a sub-menu. In the code below, as_action triggers nicely, but the a_action does not. Same for the hovered signal.
So how can you trigger an action when you click on a menu which has a submenu?
This is Python/PySide code btw.
@
menu = QtGui.QMenu()
a_action = QtGui.QAction(cat, menu)
a_action.triggered.connect(partial(some_func, some_params))
menu.addAction(a_action)a_submenu = QtGui.QMenu(name)
a_action.setMenu(a_submenu)
a_action.setCheckable(True)for i in subs:
as_action = QtGui.QAction(i, a_action)
as_action.setCheckable(True)
as_action.triggered.connect(partial(some_func, some_params))
@Thanks!
-
You don't. The action is "show the sub menu". It would be very confusing if the action does more than that.