Uploaded image for project: 'Qt for Python'
  1. Qt for Python
  2. PYSIDE-2874

Can't add more than one menu on macOS

    XMLWordPrintable

Details

    • Bug
    • Resolution: Out of scope
    • P2: Important
    • None
    • 6.7, 6.8
    • PySide
    • None
    • macOS

    Description

      So, my GUI app has 3 menus in total, which are correctly shown, alongside the menu items that each menu contains are correctly shown. But this is only the case on Windows and Linux. On macOS, on the other hand, only the firstly added menu (General) is shown, the other two are not.

      I find it peculiar that on macOS, only the firstly added menu is present and under it only the firstly added menu item is there, even though this menu has more than one menu item.

      I'm on macOS 15.0 noticing this strange behavior, but I think this was also a problem on macOS 14, if my memory serves me correctly.

      This is how I'm creating the menus and their menu items...

      from PySide6.QtWidgets import QMainWindow
      
      class MainWindow(QMainWindow):
          def __init__(self) -> None:
              # ...
              self.create_menubar()
              # ...
      
              def create_menubar(self) -> None:
                  """Create the menubar with items in separate menus."""
      
                  # Menubar
                  menubar = self.menuBar()
      
                  # General menu
                  general_menu = menubar.addMenu("General")
      
                  # Edit menu
                  edit_menu = menubar.addMenu("Edit")
      
                  # Help menu
                  help_menu = menubar.addMenu("Help")
      
                  # General menu > Load engine...
                  general_menu.addAction(self.load_engine_item)
      
                  # General menu separator
                  general_menu.addSeparator()
      
                  # General menu > Quit...
                  general_menu.addAction(self.quit_item)
      
                  # Edit menu > Settings...
                  edit_menu.addAction(self.settings_item)
      
                  # Help menu > About
                  help_menu.addAction(self.about_item)
      

      Menu items, such as self.load_engine_item and others, are defined as actions, so instances of the QAction class.

      In short, all of my code properly works on Windows and Linux, but not on macOS, definitely not on macOS Sequoia (15.0), not 100% sure for previous versions.

      Can anyone please look into this peculiarity? Thanks.

      Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            crmaurei Cristian Maureira-Fredes
            pedantichacker BoĊĦtjan Mejak
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes