Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

Catch all keyboard input?



  • I have an app I'm looking to port from MFC to Qt Widgets. One of the main features of the app is it has a completely customizable keyboard shortcut system. The way we do this now is we use the PreTranslateMessage function to process all keyboard input to the app and then compare it to the user list. If it exists we execute the attached function and stop further processing. If it doesn’t we pass it along for default processing. Is there an equivalent way to handle this in Qt? There are no input controls in the UI, but there is a list control (QTableWidget in Qt) and a bunch of buttons, so I need something that will capture the input regardless of which control has focus.



  • @Dan203
    Before going further, have you looked at QShortcut Class? Note the possibilities from enum Qt::ShortcutContext.

    Otherwise you can use a global eventFilter() which might be more like PreTranslateMessage?


Log in to reply