[Python] Trigger a QMenu submenu item through code

Discussão em 'Python' iniciado por Stack, Maio 20, 2025.

  1. Stack

    Stack Membro Participativo

    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:

    [​IMG]

    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()

    Continue reading...

Compartilhe esta Página