I am trying to trigger through code the clicking of a QMenu submenu item. For example, I want to trigger "report 2 under Jack's reports" in the following QMenu/submenu:
The following will trigger "Combined report" in the main menu:
def view(self):
report_menu = self.reportsWindow.ui.inhira_btn.menu()
report_menu.actions()[0].triggered.emit()
self.reportsWindow.show()
However, I want to trigger a submenu item (report 2 under Jack's reports). Without success, I've tried various subscriptable combinations like:
report_menu.actions()[1][1].triggered.emit()

mainMenu = QMenu()menu.subMenu = menu.addMenu('sub menu')and access them with...menu().subMenu().actions(). Note that sub menus are added as actions, not lists. Your last code is invalid becausereport_menu.actions()[1]returns an action, and therefore not iterable. You must access the menu contained in the action, and then get its own actions:report_menu.actions()[1].menu().actions()[1].