Detect arrow key input in qt

a sandwhich picture a sandwhich · Oct 30, 2010 · Viewed 14.7k times · Source

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?

Answer

Jakub Wieczorek picture Jakub Wieczorek · Oct 30, 2010

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.