I have a QDockWidget in my Mainwindow with a QTableWidget and two QPushbuttons. Of course, I can click the buttons with my mouse, but I want also to "click" them with left- and right-arrow-key.
It nearly works perfect. But before they are clicked via key, it seems like the focus jumps to the right/left of the QTableWidget (the items in it, it goes through all columns).
Is it possible that I have the KeyPressEvents only for the buttons in the QDockWidget?
You can use an event filter like this:
keep an instance of the filter class in your main window class:
then install it in your widgets, e.g. in your main window class constructor:
You may want to check for modifiers (e.g. Ctrl key), to preserve the standard behaviour of the arrow keys: