Keyboard event and text cursor for hiden widget
I've developped a widget application in QT. For now, I'm compiling for windows and I intend to compile for linux in the future.
So, my widget always stays hiden and it has an icon menu for configuring. What I need to do now is get data from the keyboard input, manipulate it and then print it into text cursor in current visible window. For example, if the cursor is on browser url, my programm should get keyboard input, manipulate it and print some data into browser url.
If it was a console, it should get data from stdin and prints something into stdout.
I've implemented using Keyboard event. Something like [URL="http://www.qtcentre.org/threads/45159-keyPressEvent-not-being-called"]http://www.qtcentre.org/threads/45159-keyPressEvent-not-being-called[/URL]
The problem is: this only woks if the widget is active, not hiden (as far as I've seen).
I'm thinking in using this: [URL="http://qt-project.org/doc/qt-4.8/eventsandfilters.html"]http://qt-project.org/doc/qt-4.8/eventsandfilters.html[/URL]. But I want to be sure it will work out.
For sending data is the "same" problem, the widget is not active, so, how to put data to cursor text? Can I use QTextCursor?
I've been trying to find out a solution without success.
Does anybody can help with this issue?
Thanks a lot.
Just a thought. Can you change how you're hiding it? For instance in QML (I know you're doing Qt Widgets) if you set the visibility to false, you can't capture events, but if you set the opacity to 0, then the item is effectively hidden but it still responds to events.
I've just tried and, unfortunately, I didn't work.
setVisible(false) -> the keyboard only if the icon menu is visible.
Opacity = 0 -> the keyboard works, but if the widget is selected. If another window , e.g. web browser, is actived, the keyboard event is not set.
Thanks for the tip.
Well, I've read some links saying to use Windows raw input:
"Windows raw input":http://www.cplusplus.com/forum/windows/95700/
For notice, I'm using QT Creator 2.4.1; QT SDK 4.8.1; MSVC 2010 compiler on windows 7.
Following these links, I'm getting compiling errors for Windows functions.