How to generate an event to ESC (Escape), F1 and such keys.
-
Here is dfaure message that was posted in the other thread:
[quote] At first sight I don’t see anything wrong with the code you posted, the problem must be elsewhere. What type of widget is “this”?
One idea could it be that the Esc key closes the dialog, and that F1 triggers some help action…In fact between posting a QKeyEvent and getting a keyEventPressed, many things can happen:
- shortcut handling (if a widget accepts the ShortcutOverride event for instance; or if a QAction exists with this key)
- event filters
Please give more information. Ideally extracting a standalone testcase, that’s the easier to look at smile. [/quote]
[cleaned up formatting and deleted the other thread = Alexandra]
-
The handler from LIRC (Linux InfraRed client or something like this) is a QObject derived class.
All the other windows are QWidgets and I'm trying to receive Keypress events in them.
I'm doind a few test on monday. Now I'm in a holliday! :D
Thanks. I'll be in touch. -
Am I getting something wrong here or is your “key interpreting” object posting events to itself.
@void QCoreApplication::postEvent ( QObject * receiver, QEvent * event )@
If that is the case than I think You should check this objects keyPressEvent, maybe those specific events get accepted by this object and their propagation stops there. -
This class is something like a keyboard driver, however not to a keyboard, it is to the IR Remote Control.
It recieves the Remote Control keypress through a socket. And that code would translate the string information about the pressed key to a QT key event.
My goal is to use this class to generate key events to the entire application.Notice that I'm generating QKeyEvents and using a signal to notify any registered slot about that too.
That's an workaround, I really want to take this signal/slots approach out and keep using the QKeyEvent part only.I believe this is how I generate key events to the entire application, so the QT framework itself decides which Widget is going to receive the event.
@
void QCoreApplication::postEvent ( QObject * receiver, QEvent * event )
@Is this wrong?
Maybe we've found the mistake. -
Maybe I'm wrong!
Now I noticed the first parameter is the RECEIVER of the Event, not the GENERATOR of the event.
Have to read a little about that.
Does anyone know something about how to generate events to the entire application (letting QT decide who is going to receive the event)? -
Just a wild guess but I would try using @QApplication::postEvent(qApp, event);@ instead of @QApplication::postEvent(this, event);@ as qApp is a pointer to the object representing the current QApplication instance. But I don't relay know if that'll result in the event being passed to the active widget I don't know.
-
I'll give a shot on Monday. Maybe we are lucky this time. Will post news asap.
-
Great idea.
I've been trying to find some time to test the last suggestion kkrzewniak made.
I'll do it ASAP and will try this too.
It sounds like will work.Thanks very much for your help.
-
That worked.
I had to make a lot of changes to fit with this.
But now, that's all fine!Thanks so much for your help guys.