Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Detect arrow key input in qt

Tags:

qt

arrow-keys

How would I detect the pressing of one of the arrow keys in qt? Also, would the application still detect them if it is minimized?

like image 739
a sandwhich Avatar asked Oct 30 '10 15:10

a sandwhich


1 Answers

How would I detect the pressing of one of the arrow keys in qt?

By handling the key press event in the top most widget in the hierarchy. See the list of key codes, the Qt::Left - Qt::Down range is what you're interested in.

Also, would the application still detect them if it is minimized?

No. It would detect them only if it had the keyboard's focus, which is not the case when minimized. You can't set up global hotkeys in a cross-platform fashion in Qt.

like image 65
Jakub Wieczorek Avatar answered Sep 30 '22 16:09

Jakub Wieczorek