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

Hiding QMenu Separators And Re-Showing Them Doesn't Always Work



    • Bug
    • Resolution: Unresolved
    • P3: Somewhat important
    • None
    • 5.15.3
    • GUI: Menus
    • None
    • iMac Pro (2017) running Big Sur 11.2.3; Qt 5.15.3
    • macOS


      Our application creates QMenu objects and calls addAction and addSeparator as appropriate. Then it hides all actions, including the separators. We have logic that decides which actions and separators we want to show and then call setVisible( true ) on them.

      I've attached source code for a simple test app I've run on Mac (Big Sur). Build and run the app. A MainWindow opens. Pull-down the Edit menu on system menu bar. You'll see a checkable and checked item named "Show Other Actions." Below it are several menu items. Note that two menu separators are present.

      Now click "Show Other Actions" and re-open the Edit menu. All the menu items below it, including the two separators, are hidden.

      Now click "Show Other Actions" and re-open the Edit menu again. The separator that used to be between "Redo" and "Cut" is NOT shown, but the second separator is.

      You can view the qDebug output and should see this:
      Hiding "Undo"
      Hiding "Redo"
      Hiding ""
      Hiding "Cut"
      Hiding "Copy"
      Hiding "Paste"
      Hiding "Delete"
      Hiding ""
      Hiding "Select All"
      Hiding "Select Range"
      Hiding "Invert Selection"
      Showing "Undo"
      Showing "Redo"
      Showing ""
      Showing "Cut"
      Showing "Copy"
      Showing "Paste"
      Showing "Delete"
      Showing ""
      Showing "Select All"
      Showing "Select Range"
      Showing "Invert Selection"

      We are clearly requesting both separators be shown, but that's not what's happening.

      In our real-world application, we suspect this bug is causing other strangeness such as showing separators between the wrong items, e.g., between "Cut" and "Copy" instead of between "Redo" and "Cut."


        Issue Links

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



              qt.team.quick.subscriptions Qt Quick and Widgets Team
              craig_kaufman Craig Kaufman
              5 Vote for this issue
              2 Start watching this issue



                Gerrit Reviews

                  There are no open Gerrit changes