QMenu action entry with ampersand shortcut

100 Views Asked by At

I tried to set an action in a QMenu with the ampersand shortcut (&) but the shortcut is not rendered. I should have a rendering like the "Help" action with the F11 shortcut.

Window screenshot

The code:

QMenu* filesMenu = ui->menubar->addMenu("&Test");
QAction* ampersandAction = filesMenu->addAction("Ampersand!");
ampersandAction->setShortcut(Qt::Key_Ampersand);
1

There are 1 best solutions below

3
Issylin On

Your code is fine and working. Just press the "Alt" touch while your app is running and your letter will be underlined as you want it to be.