问题
I'm looking at the Data Visualization Tool Tutorial on the QT website where they have an example of creating a menu bar inside a QMainWindow
:
self.menu = self.menuBar()
self.file_menu = self.menu.addMenu("File")
This doesn't work for me on OSX 10.13.6. I've also tried using QMenuBar
to create my own menu bar rather than using the default one that comes with a QMainWindow
:
menu_bar = QMenuBar()
menu_bar.addMenu('File')
self.setMenuBar(menu_bar)
This also has no effect. I never see the "File" option in the menu bar of my app. I just get a generic menu bar with a single "python" option.
回答1:
I believe it is working, but "File" will only appear once you add actions to the file menu.
menu = self.menuBar()
file = menu.addMenu('File')
file.addAction(QAction('Open...', self))
来源:https://stackoverflow.com/questions/60290777/how-to-create-a-menu-bar-on-osx-with-pyside2