PDA

View Full Version : QMessageBox Key focus



mickeyk191
13th April 2010, 16:21
Hi all

I have a embedded application where I have 3 hardware push buttons as the only user input. I have linked these buttons to 3 different keyboard keys (Q,W and E) so I can use the button input in my Qt application.
Therefore throughout my application I use QKeyEvent to tell the application what each button should correspond to depending on where I am in the program. Eg Tab, Space, Up, Down etc

However when I call a QMessageBox within my Main application like:
msgBox->warning(this,tr("No Selection made!"),tr("You must choose an Answer to proceed"));

I cannot get my QKeyEvent to focus on the new message box window, it is still focused on the main window behind it.
I can press the "OK" button with the space bar on a keyboard but I cant create an event filter to simulate the space bar with the letter W for example.

How do I get my event filter to focus on the new QmessageBox that has been created or how do I create a seperate Event filter for the message box?


Please Help

JohannesMunk
14th April 2010, 10:12
Hi!

Have you tried to set the focus manually? msgBox->setFocus();

I'm not sure what you want to say with "event filter to focus".. Do you use msgBox->installEventFilter(this) .. ?

If that doesn't help you need to show us some code!

Johannes