Pyqt - 将QMenuBar添加到另一个类中的QMainWindow

问题描述 投票:0回答:1

我有2个类:MainWindow()和Menubar()。 MainWindow()是QMainWindow,Menubar是QMenuBar。我不知道如何将菜单栏添加到主窗口。

使用QToolBar,我可以做这样的事情:

self.toolbar = Toolbar() self.addToolBar(self.toolbar)

但是使用QMenubar,没有像“addMenuBar()”这样的函数。

所以我无法弄明白。

python-3.x pyqt pyqt5
1个回答
1
投票

QMainWindow带有默认的QMenuBar,但你可以用QMainWindow.setMenuBar()设置一个新的

更多关于Qt Documentation的信息

© www.soinside.com 2019 - 2024. All rights reserved.