Question: 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](https://i.stack.imgur.com/iD1YK.png)

Answer: 
From Qt 5.2 onwards, you can use [QKeySequenceEdit](https://qt-project.org/doc/qt-5-snapshot/qkeysequenceedit.html) for this purpose
Qt Creator is actually open source. So if you want exactly what that dialog does, you can peek in and see how they do it.

The implementation of that *"Edit Action"* dialog is in a library called "QtTools". Here's the header and the source file:

[actioneditor\_p.h](http://qt.gitorious.org/qt/qttools/blobs/master/src/designer/src/lib/shared/actioneditor_p.h)

[actioneditor.cpp](http://qt.gitorious.org/qt/qttools/blobs/master/src/designer/src/lib/shared/actioneditor.cpp)

...but it looks to be a bit indirect, and bootstrapped onto the form engine itself. You'd have to dig a while to get to the part where it actually captures the key sequence. Casual browsing sans debugger suggests it is `QtKeySequenceEdit` implemented in these files:

[qtpropertybrowserutils\_p.h](http://qt.gitorious.org/qt/qttools/blobs/master/src/shared/qtpropertybrowser/qtpropertybrowserutils_p.h)

[qtpropertybrowserutils.cpp](http://qt.gitorious.org/qt/qttools/blobs/master/src/shared/qtpropertybrowser/qtpropertybrowserutils.cpp)