PDA

View Full Version : focus out event and cursor issue



sajis997
27th February 2012, 01:51
Hello forum,

i have a line edit and i want to do some validation check upon the focus out event. If the validation returns a false i show a message box set the focus back to the line edit and the cursor as well. Otherwise the focus moves along with the cursor to the other widget in the layout.I am over-ridding the focusOutEvent() function as follows:

This is the minimal example i think



void H3DNodeDEFLineEdit::focusOutEvent(QFocusEvent *event)
{
if(event->reason() == Qt::TabFocusReason)
{
QMessageBox msgBox;
msgBox.setText("Tab for the focus out event");
msgBox.exec();

}
}



Now i am having the following behavior:

With the tab key i get the message box and the focus moves to another widget along with the cursor. But the current line edit still holds the focus and the cursor. How to remove this ?


Thanks
Sajjad

ChrisW67
27th February 2012, 03:55
Why not use QValidator?