Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
How can I grab keyboard input event without showing widget?
I using Qt 4.8.3 + DirectFB on embedded system(ARM-Core).
When I run my application, that has QMainApplication and widgets.
But all widgets are hiding.
I want to show widgets when I push keyboard.
At this time, how can I grab keyboard input on QMainApplication?
There's no QMainApplication class in Qt.
You can intercept all the app keyboard in a couple of ways.
One of them is installing an event filter on the
qAppobject and fishing for
Thank you for reply.
I made mistake. I mean QApplication, not QMainApplication.
So, I using test code like below link.
When I call "main.show()", then eventFilter-KeyPress- working well.
But delete "main.show()", then eventFilter-KeyPress not triggered.
Is there no way grab keyboard input without showing widget?
Oh, I misunderstood then.
Qt can only expose events it receives from the OS. An app that does not have any windows does not receive any keyboard events from OS.
For that you would have to hook into the keyboard events directly, which is highly platform specific and beyond what Qt provides.
You might look into 3rd party libraries for this functionality, for example QxtGlobalShortcut, but you'd have to check if it's available for your target platform.
I add a widget that always showing in geometry(0,0,1,1).
This widget grab keyboard input and pass to QApplication.
It not perfect but looks okay for my target platform :-).
Thank you for kind reply and have a good day.