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

Submenus are disabled on Mac OSX with native menu after QMenu::clear()

    XMLWordPrintable

Details

    • Bug
    • Resolution: Duplicate
    • P2: Important
    • 5.6.2
    • 5.6.0, 5.6.1, 5.7.0
    • None
    • Mac OSX, Native menubar
    • macOS
    • 38b09d34210805766afa8bdd6a1ef413447a89ed

    Description

      On Mac OSX with enabled native menubar, if you call clear() on a menu added to the menuBar and repopulate it, the added submenus will be showed as disabled. This didn't happened on Qt 5.5, but it happens on Qt 5.6, Qt 5.7 and the dev brach.

      In our mdi application we call clear and repopulate the menus to update their content according the current selected document.

      Attached you find an example to reproduce the problem. Below an excerpt and a screen shot.

      #include "mainwindow.h"
      #include "ui_mainwindow.h"
      
      MainWindow::MainWindow(QWidget *parent) :
         QMainWindow(parent),
         ui(new Ui::MainWindow)
      {
         ui->setupUi(this);
      
         // Create a submenu with some actions
         subMenu11 = new QMenu("Menu 1.1", this);
         subMenu11->addAction("Action 1");
         subMenu11->addAction("Action 2");
         subMenu11->addAction("Action 3");
      
         // Create a main menu
         menu1 = new QMenu("Menu 1", this);
         menu1->addMenu(subMenu11);
      
         menuBar()->addMenu(menu1);
      
         // Update the main menu before the menu is shown
         connect(menu1, SIGNAL(aboutToShow()), this, SLOT(updateMenu1()));
      }
      
      MainWindow::~MainWindow()
      {
         delete ui;
      }
      
      void MainWindow::updateMenu1()
      {
         menu1->clear();
         menu1->addMenu(subMenu11);
      
         // BUG:
         // With Dev / Qt 5.7 / 5.6 the sub menu 'subMenu11' is now displayed as disabled
         // With Qt 5.5 the sub menu 'subMenu11' was displayed as enabled with
         // the corresponding actions "Action 1", "Action 2", ...
      }
      

      Attachments

        Issue Links

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

          Activity

            People

              dedietri Gabriel de Dietrich (drgvond)
              lsbts1291 Lorenzo Sinigaglia
              Votes:
              1 Vote for this issue
              Watchers:
              5 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Gerrit Reviews

                  There are no open Gerrit changes