Search code examples
qtarrow-keys

Detect arrow key input in qt


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?


Solution

  • 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.