Like this, I wanna print the shortcut text.
But I don't wanna use code like this :
this->newAction->setShortcut(QKeySequence::New);
Because I handle shortcuts by using my KeyAction
classes.
If I use setShortcut()
, my KeyAction classes is ignored.
Is there any solution for only printing shortcut text?
Or Do I have to set text like "새 파일(&N)\t\tCtrl + N" ?
I wanna print text aligned.
Thanks for your help.
Answer based on the comments of TFry.
Set the shortcut as usual (using QAction::setShortcut
).
To prevent triggering the action and to stop the event-propagation when the shortcut is pressed, you must accept all ShortcutOverride
-events in the top-level window (i.e., MainWindow
, usually):
MainWindow::MainWindow(...)
{
installEventFilter(this);
}
bool MainWindow::eventFilter(QObject* o, QEvent* e)
{
if (o == this && e->type() == QEvent::ShortcutOverride) {
e->accept();
}
return QMainWindow::eventFilter(o, e);
}