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?

1 Answer 1

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

1
  • thx for a piece of advice. But main question for me is how to get QKeySequence from QKeyPressEvent
    – Ruslan F.
    Oct 28, 2013 at 16:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.