Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to implement shortcut input box in Qt

Tags:

c++

shortcut

qt

In software like qtcreator you can see things like this:

enter image description here

Basically some box which when clicked ask you to press some keyboard combination in order to record a shortcut.

How can I create something like that in Qt? I was able so far to implement this only using a regular text box in which user had to type the combination themselves and if it wasn't correct message box appeared, but it would be much more simple if users didn't have to type things like "ctrl + f2" but instead click these keys.

Is there any Qt widget for this?

like image 483
Petr Avatar asked Dec 12 '25 13:12

Petr


1 Answers

Use QKeySequenceEdit, available since Qt 5.2. It allows you to record shortcut key like in Qt Designer.

like image 131
fxam Avatar answered Dec 14 '25 04:12

fxam