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

Shortcuts don't show up in context menus

XMLWordPrintable

    • Linux/X11, Windows
    • cc33dd079796437bafed8f42de7fbf8f17d19ec8 (qt/qtbase/5.13), ba639edd2 (dev)

      Qt 5.10 introduced Qt::AA_DontShowShortcutsInContextMenus attribute to allow hiding shortcuts in context menus. The previous behavior (showing shortcuts) is set as default (attribute set to false).

      Unfortuanely it is broken (at least on Windows) and shortcuts don't show up at all no matter if the attribute is set to true or false. 

       

      Sample code:

      #include <QApplication>
      #include <QWidget>
      #include <QAction>
      
      int main(int argc, char *argv[])
      {
          QApplication a(argc, argv);
      
          QWidget w;
          w.setContextMenuPolicy(Qt::ActionsContextMenu);
      
          QAction act("Copy", nullptr);
          act.setShortcut(QKeySequence::Copy);
          w.addAction(&act);
      
          w.show();
      
          return a.exec();
      }

        1. Qt5.11.1.png
          1 kB
          Krzysztof Kawa
        2. Qt5.9.6.png
          0.9 kB
          Krzysztof Kawa
        For Gerrit Dashboard: QTBUG-69452
        # Subject Branch Project Status CR V

            richard Richard Moe Gustavsen
            chrisaverage Krzysztof Kawa
            Votes:
            10 Vote for this issue
            Watchers:
            21 Start watching this issue

              Created:
              Updated:
              Resolved:

                There are no open Gerrit changes