Search code examples
qtqt4qlineedit

How to create a hotkey field in Qt


What is the easiest way to allow user to input a key combination? It would basically look like QLineEdit field but it would accept key combinations only.

For example, there is something already in the Qt Designer where you can assign a shortcut for an Action. My requirement is exactly the same. TIA

Edit Action - assigning a shortcut


Solution

  • From Qt 5.2 onwards, you can use QKeySequenceEdit for this purpose