Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-38135

After a call to QMenuBar::clear(), then rebuilding menus, most menus are invisible (OS X).

    XMLWordPrintable

Details

    • macOS
    • efa7a5a659696901fddc8a93f870d1b83473dc64

    Description

      Background: I'm building a cross-platform MDI style app with two different window types that each require a different set of main menus. When a window is activated, I want to rebuild the QMainWindow's menu bar to display the appropriate set of menus. I'm seeing a menubar refresh problem under Mac OS X.

      What I've done: taken the Qt Examples program mdi, and modified it slightly by adding two menu items under the File menu. These either add or remove an "Extra" menu.

      Specific problem: the app calls this function...

      void MainWindow::showExtraMenu()
      {
      extraMenuIsActive = true;
      menuBar()->clear();
      createMenus();
      }

      After executing this function, only two menu bar items are visible: the 'apple' menu and the 'mdi' application menu. The 'File', 'Edit', 'Extra' and 'Window' menus are invisible.

      However, if you select the menu item 'mdi -> About mdi', then click OK, the missing menus appear. It seems that sending the main window behind the 'about' dialog, then bringing it to the front, refreshes the rebuilt menu bar. Similarly, clicking on another application then back to 'mdi' will refresh the menu.

      This should be a simple fix - refresh the menu bar after a call to menuBar()->clear();

      Attachments

        1. main.cpp
          2 kB
        2. mainwindow.cpp
          14 kB
        3. mainwindow.h
          4 kB
        4. mdi.pro
          0.3 kB
        5. mdi.qrc
          0.3 kB
        6. mdichild.cpp
          5 kB
        7. mdichild.h
          3 kB
        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            dedietri Gabriel de Dietrich (drgvond)
            johnc3 John Clements
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes