PDA

View Full Version : focusOut- event issue



gunhelstr
8th May 2006, 11:25
My problem is:


I want to catch focus-out event from some QDateEdits
This works fine if one of their siblings, which are not QDateEdits, is the next who gets focus.
But if the focus is handed over to some other widget my program ends up in a loop where
the QDateEdit who lost focus seems to go on loosing focus forever.


This is essensially how my eventFilter looks...........


bool MyWidget::eventFilter( QObject *obj, QEvent *ev )
{

if(obj == myDateEdit ){

if(ev->type() == QEvent::FocusOut){

bool ok = true;

if(<some condotion>) ok = false;

if(!ok) QMessageBox::information(0, "Message", "Condition is met","Ok");

((QDateEdit*)obj)->clearFocus();
return true;
} else return false;
}
else return QWidget::eventFilter(obj,ev);
}


How can I detect the situation where focus is handed over to some widget that is not a sibling?

zlatko
8th May 2006, 11:36
I dont know is it eactly what you whant but try reinplement boolQWidget::focusNextPrevChild ( bool next ) [virtual protected]
for your QDateEdit.

gunhelstr
8th May 2006, 13:53
I dont know is it eactly what you whant but try reinplement boolQWidget::focusNextPrevChild ( bool next ) [virtual protected]
for your QDateEdit.


Thanks. I just made a call to focusNextPrevChild(..), and my problem whas solved, almost.

What remains is: when a sibling gets focus, one focus-out event occurs
when some other widget gets focus, two focus_out events occurs.

If you can explain the reason for that, it would help me solve another problem.

zlatko
9th May 2006, 08:02
when some other widget gets focus, two focus_out events occurs.


For what widget?