What exactly does refresh() do? Why do you need to call it? Why don't you just intercept the focus-in event of the button you want?
What exactly does refresh() do? Why do you need to call it? Why don't you just intercept the focus-in event of the button you want?
Hi,
I didnt put any break points. Instead of refresh() I put the below code in the if condition to test. But the message box didnt pop up
void testApp::keyPressEvent(QKeyEvent *event)
{
if(event->key() == Qt::Key_Down && buttons[9]->hasFocus())
{
QMessageBox msgBox;
msgBox.setText("The document has been modified.");
msgBox.exec();
}
}
When the condition is if(event->key() == Qt::Key_Down )
and press down key its working but when I try checking focus on the last button its not.
I set setFocusPolicy(Qt::StrongFocus); in the widget.
Please help .Thank you.
Added after 4 minutes:
Hi ,
In refresh(), I want to update the text of all the 10 pushbuttons. I want to call this function when the 10th button is reached and then down key is pressed. That is the case I tried to put in the if condition.
Last edited by AmulyaT; 5th April 2013 at 04:53.
you should use ["code"] and [/"code"] btw, and if it works with out it seems to me like that button isn't getting focus did you try with out that condition? egQt Code:
if(buttons[9]->hasFocus()){ msg.exec(); }To copy to clipboard, switch view to plain text mode
Thanks. You are right. It is not getting the focus. But then when I use the arrow keys I see that it is going to that button..it is highlighted. Then which property do we need to use ? Or do we need to explicitly set something ?Can anybody suggest ?
Thanks.
1.As Wysota mentioned, Why you want that logic?I am trying to refresh the text on the pushbuttons once the last pushbutton on the screen is reached.
2.Did you tried what wysota said?
Key press event is a costly event, since it will trigger at every key press. But what you need is, do something on the last button focus. So just use focus-in eventWhy don't you just intercept the focus-in event of the button you want?
Hope it helps,
Bala
Bookmarks