Reputation: 540
I am using PyQt5 and Qt Designer to make ui, and now I want to add a QAction in the menu bar. It seems that I am not able to do this in Qt Designer, so I think manually coding is needed. I tried using insertAction(), but I get
TypeError: insertAction(self, QAction, QAction): argument 1 has unexpected type 'QMenu'
It looks like that insertAction() can only insert before QAction, and I want to insert before QMenu.
Is it possible to insert QAction before a QMenu, or I have to add QMenu manually after I add QAction?
Upvotes: 1
Views: 792
Reputation: 48260
Every QMenu in Qt5 has a menuAction()
that refers to the QAction of that menu; if you want to add an action before that menu, you must use that action reference:
self.someMenu.insertAction(otherMenu.menuAction(), action)
Upvotes: 2