Make application to respond to space bar presses/releases
I need to make my application to respond to space bar press and release events. Autorepeats must be filtered out in order to respond only to actual key presses and releases (the key may be pressed and hold for a few seconds), so, as I understand, I cannot use the shortcut mechanism present in Qt.
I have tried to reimplement keyPressEvent/keyReleaseEvent or eventFilter in the application's main window class. Initially both of these approaches work, but after adding some child widgets to the main window it stops to respond to KeyPress events, and after selecting one of the child widgets (e.g. a radio button) KeyRelease events also disappear. I understand that the events are intercepted by child widgets, but I do not know how to disable such behavior.
The main window has several tabs and one of them contains a text editor. Ideally I would like to completely disable processing of space bar events in the main window by anything except my own handlers when the editor tab is not selected. Separate dialog windows also need to work as usual, because they have some text input fields. The application is cross-platform and solution to this problem also has to be OS agnostic. Is it possible?
You can simply add a event filter to your application, then you can deal with all the spaceBar press/release event there.
Thank you, it seems to be working. As I understand, I have to remove the filter each time before showing a dialog and to reinstall it afterwards, but fortunately there are only a few dialog calls.