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

styleHints()->setShowShortcutsInContextMenus(true) has no effect

    XMLWordPrintable

Details

    • macOS
    • ba639edd2 (dev)

    Description

      On macOS, the shortcut in context menu is not shown by default.
      To override this behavior,

      styleHints()->setShowShortcutsInContextMenus(true)
      

      can be set.
      However, this does not have any effect in Qt5.15.
      This works in older Qt versions, e.g. Qt5.14.

      Sample code is below and a sample project is attached( qtbug109590-showshortcut.zip ).
      In order to show the context menu, press secondary click anywhere in the window.

      int main(int argc, char *argv[])
      {
          QApplication a(argc, argv);
          a.styleHints()->setShowShortcutsInContextMenus( true );
      
          QWidget w;
          w.setContextMenuPolicy(Qt::ActionsContextMenu);
      
          QAction act("Copy", nullptr);
          act.setShortcut(QKeySequence::Copy);
          // act.setShortcutVisibleInContextMenu(true);  // Workaround
          w.addAction(&act);
      
          w.show();
      
          return a.exec();
      }
      

      Attachments

        Issue Links

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

          Activity

            People

              vestbo Tor Arne Vestbø
              nagrohn Nahomi Gröhn (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Gerrit Reviews

                  There are no open Gerrit changes