For a key event to be delivered you need to have an active widget that accepts focus. Then this key event is delivered to that widget and will be intercepted by the global event filter.
For a key event to be delivered you need to have an active widget that accepts focus. Then this key event is delivered to that widget and will be intercepted by the global event filter.
If you need a platform-independent way of solving your problem, you might need something like ncurses. If you are targeting POSIX-compliant systems, you may use QSocketNotifier to monitor input on stdin. This is a bit primitive, but it should work. For anything fancy I would recommend looking into ncurses (although I have never used it myself).
Wysota, the application is a console app. There is no widget. Is it in this case impossible to intercept keystrokes with eventFilter?
I'd rather not include another lib, but I will have look at QSocketNotifier to see if I understand how to use it to catch keystrokes. Whether it works or not: thanks for the suggestion!
Exactly. Thus you will not get any key events. You can use QSocketNotifier on STDIN to get line-buffered input notifications.
Bookmarks