PDA

View Full Version : spinbox ClearFocus()



RENOLD
1st February 2012, 12:51
In my qt code I want to go to another page from 1st page(means I enter the number where I want to go and press enter and that page will be open). To do so I use spinBox,

if(e->key() == Qt::Key_F)
{
spinBox->setFocus();
}

if(e->key() == Qt::Key_G)
{
spinBox->ClearFocus();
}

When I press F it set the focus of spinBox, But the problem is that when once the focus is set I can not come out from that(my Key_G is not detected).
So please help me to come out from that focus so I can go ahead in my project.

-Renold

wysota
1st February 2012, 13:25
Since the spinbox has focus, it receives all key events so obviously your key handlers are only invoked when a particular widget has focus. To circumvent that you can install an event filter on the application object to intercept all events before they reach their targets.

RENOLD
3rd February 2012, 13:21
Thanks for your reply,
I am very new in QT.
Can you please tell me how can I install an event filter on the application object.?

wysota
3rd February 2012, 13:25
You can open Qt reference manual, switch to the index tab and type in "event filter".

RENOLD
6th February 2012, 11:11
Hey dear I go through Qt reference manual now I want to know that on which object I have to install event filter of my program? In function setFocus()?

wysota
6th February 2012, 11:27
on which object I have to install event filter of my program?
Read my post again.

RENOLD
10th February 2012, 04:42
Thank you.... I completed it.... I am very happy.... :)