The documentation on assigning a shortcut to a QPushButton is as follows:
A shortcut key can be specified by preceding the preferred character with an ampersand in the text. For example:
QPushButton *button = new QPushButton("&Download", this);
In this example the shortcut is Alt+D.
What do I do if I don't want an Alt+[A-Z]
shortcut? For example, in my case I want my button to be fired when the TAB
button is pressed. How can I achieve this effect?
You can use setShortcut
method, eg:
pushButton->setShortcut(QKeySequence(Qt::Key_Tab));
It will fire then slots assigned to the clicked()
signal