I am handling a key pressed event in a widget by overloading a void keyPressEvent ( QKeyEvent* eventPtr )
method.
The problem is that when I launch two instances of my application (from the Qt Creator) only one of them effectively handles the key pressed event. Even when I set focus on the second window it does not receive the events. When I set focus on the first one it actually does receive the event.
All other functionality works fine when two applications are launched.
Is it an expected behavior or a known issue or maybe I am missing something?
UPD: I found out that some key presses (e.g. letters) are actually received by both windows. But only one window receives arrow key presses. When I create an instance of my widget I call widget->setFocus()
on it. This makes the widget receive arrow key presses. But this does not work when two instances of the application are launched.
Maybe I should use event filter instead?
keyPressEvent
is being executed only in one instance of the application. – KolyunyakeyPressEvent
because the breakpoint is not being reached. – KolyunyaqDebug()
inside the event handler printed something only to the first window's console. – Kolyunya