0

To make my application more flexible to user I want to add possibility user to chose Hot keys for some actions in app.
To do this I'll gooing to make some page on settings window.
where Action name and input(QLineEdit) where keys will be desplayd like
Quit |Alt+Q|
What was the best way to capture such Hot Keys?

Ruslan F.
  • 5,498
  • 3
  • 23
  • 42

1 Answers1

0

Well, to start with, you can setShortcut for your QAction, which will do exactly what you want (trigger QAction, when user hit sequence), example:

myAction->setShortcut(QKeySequence(Qt::Key_Backspace));

for more details, look up documentation of QKeySequence class

EDIT: to grab the sequence itself, look here - https://stackoverflow.com/a/6665017/1741118 . This answer should work. You can derive from widgets, where you would enter sequence, override QKeyPressEvent there or just set QEventFilter on every widget, that you want to capture events for key sequence

Community
  • 1
  • 1
Shf
  • 3,463
  • 2
  • 26
  • 42