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

Menu bar scope vs presentation, and related issues

    XMLWordPrintable

Details

    • Task
    • Resolution: Unresolved
    • P2: Important
    • None
    • None
    • None
    • All

    Description

      This task tries to document two related but distinct aspects of how menu bars are handled in Qt, and some of the current issues.

      The two aspects are:

      1. The scope of the menu bar, ie when should the menu bar apply
        • Per window
        • Application global
      2. The presentation of the menu bar, ie where is it "drawn"
        • In-window (e.g. Windows)
        • App/system-global (e.g. macOS)

      Details

      • Per-window
        • Created via
          • QMenuBar(widgetParent)
          • ApplicationWindow.menuBar: MenuBar {}
            • ⚠️ Or Window { MenuBar {} }, but undocumented
        • Presentation
          • In-window
            • Typically done by Qt faking a menu bar
            • ⚠️ Although we could potentially use native APIs on e.g Windows to create these
            • ⚠️ We currently treat createPlatformMenuBar() as a way to create global native menu bars only.
              • ⚠️ This also applies to AA_DontUseNativeMenuBar which is not clear on whether it applies only to global native menu bars, or all native menu bars (including in-window native menu bars).
          • App-global
            • Represented in the native menu bar by switching the global menu bar based on which window has focus
            • ⚠️ However our logic, at least on macOS, is very naive, and doesn’t account for (transient) parent relationships
            • ⚠️ As a workaround (presumably) we don’t clear the global menu bar if a window without a per-window menu bare is active, but instead just leave the current menu bar as is
              • Without this all dialogs and context menus would result in losing the per-app menu bar (temporarily)
      • App-global
        • Created via
          • QMenuBar(nullptr)
          • ⚠️ No documented QML API
            • But a MenuBar without a parent Window results in a global menu-bar
        • Presentation
          • App-global
            • Represented as a native menu bar
            • ⚠️If a window has a more specific menu bar, the global menu bar is ignored, ie we do not merge them in any way.
          • Per-window
            • ⚠️ Completely ignored
            • We do not automatically represent the global menu bar as in-window menu bars for those windows that don’t have a specific menu bar
            • And probably shouldn’t, as we don’t want every dialog or popup to have them. But perhaps specific window types should at least gain the global menu bar?

      Or represented as a table:

       

      Scope/Presentation                                                                        In-window (e.g. Windows)                                                               App-global (e.g macOS)
      Per-window (has a window parent) Represented as an in-window menu bar rendered fully by Qt. ⚠️ We could create native in-window menu bars. But we currently treat createPlatformMenuBar() as a way to create global native menu bars only. This also applies to AA_DontUseNativeMenuBar which is not clear on whether it applies only to global native menu bars, or all native menu bars (including in-window native menu bars). Represented in the native menu bar by switching the global menu bar based on which window has focus.  ⚠️ If a window gains focus that doesn’t have an associated menu bar we just leave the current one as is, which depends on which window had focus previously. ⚠️We’re not following window (transient) parent chains when resolving which menu bar is most relevant for the given focus window.
      App-global (parent-less) ⚠️ Completely ignored. We do not automatically represent the global menu bar as in-window menu bars for those windows that don’t have a specific menu bar. And probably shouldn’t, as we don’t want every dialog or popup to have them. But perhaps specific window types should at least gain the global menu bar? Represented as a native menu bar. ⚠️If a window has a more specific menu bar, the global menu bar is ignored, ie we do not merge them in any way.

      Attachments

        Issue Links

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

          Activity

            People

              qt.team.quick.subscriptions Qt Quick and Widgets Team
              vestbo Tor Arne Vestbø
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:

                Gerrit Reviews

                  There are no open Gerrit changes