I’m following a tutorial to create a PySide6 application with a menu bar, but I’m running into an issue on macOS Sonoma 14.4.1. The person doing the tutorial is using Windows OS, and everything works fine for them, but on my macOS system, the “File” menu does not appear until I add more than one action. Even then, only one of the actions is shown.
Here’s the code:
main.py
from PySide6.QtWidgets import QApplication
import sys
from mainwindow import MainWindow
app = QApplication(sys.argv)
window = MainWindow(app)
window.show()
app.exec()
mainwindow.py:
from PySide6.QtWidgets import QMainWindow
class MainWindow(QMainWindow):
def __init__(self, app):
super().__init__()
self.app = app
self.setWindowTitle("Custom main window")
menu_bar = self.menuBar()
file_menu = menu_bar.addMenu("&File")
file_menu.addAction("Quit")
file_menu.addAction("Save")
Issue:
The “File” menu does not appear until I add more than one action.
Even when the menu appears, only the last action (“Save”) is displayed.
The “Quit” action does not show up.
System Details:
Operating System: macOS Sonoma 14.4.1
PySide6 Version: 6.7.0
What I’ve Tried:
- Adding multiple actions to see if the menu appears.
- Rearranging the order of actions.
- Adding the application name and organization name, to help macOS correctly associate the menu with the application, as follows:
app.setApplicationName("Custom App")
app.setOrganizationName("YourOrganization")
None of this worked.