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

MacOS native menubar setEnable(true) on QMenu does nothing in some cases

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Cannot Reproduce
    • Icon: P3: Somewhat important P3: Somewhat important
    • None
    • 5.9.2
    • Widgets: Main Window
    • None
    • macOS

      I have a QMenu (menu2) inside another QMenu (menu1) itself belonging to a QMenuBar. At the beginning menu2 is empty and disabled, and menu1 is enable.

      The application (QWidget based) populates menu2 based on some items, and updates menu2 if the number of items changes. Basically doing this:

      menu2->clear();
      foreach(const Item &item, items)
          menu2->addAction(item.text());
      menu2->setEnabled(!items.isEmpty());

      Very often (90% of cases), menu2 ends up disabled, even though items is not empty. Note that the menu itself is not greyed, but all actions inside are disabled.

      I found a turnaround. If I put menu2->setEnabled(false); before menu2->setEnabled(!items.isEmpty()); then the problem disappears.

      Also, if I turn off nativeMenuBar on the menubar, then again the problem is fixed.

      This problem occurs only on MacOS. On all other platforms (Windows/Linux/iOS/Android/Raspberry) the same code works as expected.

      The bad news is that I tried very hard to reproduce this in a small sample, but did not succeed. So there must be something special in my settingsĀ that I didn't catch. The application has several toolbars, a status bar, a QGraphicsScene and many other stuff, I don't know if that can explain this.

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

            tpochep Timur Pocheptsov
            matirai Philippe
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved:

                There are no open Gerrit changes