Details
-
Bug
-
Resolution: Unresolved
-
P1: Critical
-
None
-
6.8
-
None
-
PySide6 version: 6.8.0.2
Python version: 3.x
OS: macOS
Description
When creating a Window menu in a QT / PySide6 application on macOS, the native menu items (Minimize, Zoom, Center, Move and Resize, etc.) are not automatically added to the Window menu as they should be according to macOS Human Interface Guidelines. However, it does add native appropriate menu items for Edit and Help menus.
According to Apple's Human Interface Guidelines (https://developer.apple.com/design/human-interface-guidelines/the-menu-bar#Window-menu), these menu items should be provided automatically when creating a Window menu on macOS.
Steps to reproduce:
- Create a minimal PySide6 application on macOS with a Window menu
- Run the application
- Observe the Window menu contents
Expected behavior:
Window menu should automatically include standard macOS items:
- Minimize (⌘M)
- Zoom
- Center
- Bring All to Front
- Move and Resize
- Full Screen Tile
- etc
Actual behavior:
- Window menu only shows manually added items
- No native macOS menu items are automatically added (they are however added for Edit and Help menus, just not added for Window Menu)
- Menu disappears completely if no manual items are added
Environment:
- PySide6 version: 6.8.0.2
- Python version: 3.x
- OS: macOS
Minimal reproducible example:
from PySide6.QtGui import QAction from PySide6.QtWidgets import QApplication, QMainWindow, QMenu import sys class TestWindow(QMainWindow): def __init__(self): super().__init__() self.setWindowTitle("Test Window Menu") menubar = self.menuBar() menubar.setNativeMenuBar(True) edit_menu = QMenu("Edit", menubar) minimize_action = QAction("Dummy Action", edit_menu) edit_menu.addAction(minimize_action) window_menu = QMenu("Window", menubar) minimize_action = QAction("Dummy Action", window_menu) window_menu.addAction(minimize_action) help_menu = QMenu("Help", menubar) minimize_action = QAction("Dummy Action", window_menu) help_menu.addAction(minimize_action) menubar.addMenu(edit_menu) menubar.addMenu(window_menu) menubar.addMenu(help_menu) app = QApplication(sys.argv) window = TestWindow() window.show() sys.exit(app.exec())
PS: I had originally created this ticket but was requested to create a ticket in the QTBUG project using a C++ code snippet.
I haven't tested it using C++ but here is a snippet generated by Claude
#include <QApplication> #include <QMainWindow> #include <QMenu> #include <QMenuBar> #include <QAction> class TestWindow : public QMainWindow { public: TestWindow() : QMainWindow() { setWindowTitle("Test Window Menu"); QMenuBar* menubar = this->menuBar(); menubar->setNativeMenuBar(true); // Edit Menu QMenu* edit_menu = new QMenu("Edit", menubar); QAction* edit_action = new QAction("Dummy Action", edit_menu); edit_menu->addAction(edit_action); // Window Menu QMenu* window_menu = new QMenu("Window", menubar); QAction* window_action = new QAction("Dummy Action", window_menu); window_menu->addAction(window_action); // Help Menu QMenu* help_menu = new QMenu("Help", menubar); QAction* help_action = new QAction("Dummy Action", help_menu); help_menu->addAction(help_action); // Add menus to menubar menubar->addMenu(edit_menu); menubar->addMenu(window_menu); menubar->addMenu(help_menu); } }; int main(int argc, char *argv[]) { QApplication app(argc, argv); TestWindow window; window.show(); return app.exec(); }
Attachments
Issue Links
- relates to
-
PYSIDE-2934 PySide6: Native macOS Window menu items not automatically added
-
- Closed
-