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?
Asked
Active
Viewed 528 times
0

Ruslan F.
- 5,498
- 3
- 23
- 42
1 Answers
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
-
thx for a piece of advice. But main question for me is how to get QKeySequence from QKeyPressEvent – Ruslan F. Oct 28 '13 at 16:08