In trying to port a QQC1 menu in ELisa to QQC2, I ran into an issue of being unable to replicate the full functionality available in QQC1, with the menu items having keyboard shortcuts that appear on the right-side of their menu items. Here's the original code (from https://cgit.kde.org/elisa.git/tree/src/qml/ApplicationMenu.qml:) import QtQuick 2.7 import QtQuick.Controls 1.4 Menu { MenuItem { text: configureAction.text shortcut: configureAction.shortcut iconName: elisa.iconName(configureAction.icon) onTriggered: configureAction.trigger() } } And here's a QQC2 version: import QtQuick 2.7 import QtQuick.Controls 2.5 Menu { MenuItem { text: configureAction.text icon.name: elisa.iconName(configureAction.icon) onTriggered: configureAction.trigger() visible: configureAction.text !== "" Shortcut { sequence: configureAction.shortcut context: Qt.ApplicationShortcut onActivated: configureAction.trigger() } } } With this, the shortcut works, but the does not visible appear in the menu itself. Or consider the following alternative using Actions in the Menu import QtQuick 2.7 import QtQuick.Controls 2.5 Menu { Action { text: configureAction.text shortcut: configureAction.shortcut icon.name: elisa.iconName(configureAction.icon) onTriggered: configureAction.trigger() } } With this, the shortcut neither works, nor visibly appears in the menu. I feel like one or both of these should work.
Git commit 721c348d1a1e903fdeb034afa8e8c03487d67301 by Alexander Stippich. Committed on 29/06/2019 at 09:49. Pushed by astippich into branch 'master'. Show shortcut in menu item when specified Summary: Show the shortcut as text for menu items when they are given via an action Reviewers: mart, ngraham, apol Reviewed By: ngraham, apol Subscribers: apol, plasma-devel Tags: #plasma Differential Revision: https://phabricator.kde.org/D21944 M +14 -0 org.kde.desktop/MenuItem.qml https://commits.kde.org/qqc2-desktop-style/721c348d1a1e903fdeb034afa8e8c03487d67301