void DlgHtmlMessage::focusOutEvent ( QFocusEvent * event ) { close();}
this->installEventFilter(this);
bool DlgHtmlMessage::eventFilter(QObject *obj, QEvent *event) { if (event->type() == QEvent::WindowDeactivate) { close(); return true; } return QObject::eventFilter(obj, event);}
C++ (Qt) QStateMachine* machine = new QStateMachine(this); QState* s1 = new QState(machine); QEventTransition* evTrans = new QEventTransition(this, QEvent::WindowDeactivate); evTrans->setTargetState(s1); s1->addTransition(evTrans); connect(evTrans, SIGNAL(triggered()), SLOT(close())); machine->setInitialState(s1); machine->start();