Install an event filter to detect QEvent::Close, e.g.
#include <QtGui>
class EventSignaller
: public QObject{
Q_OBJECT
signals:
void closing();
protected:
{
if(event
->type
() == QEvent::Close) emit(closing());
return QObject::eventFilter(object, event
);
}
};
int main(int argc, char *argv[])
{
w1.setWindowTitle("w1");
w1.show();
w2.setWindowTitle("w2");
w2.show();
EventSignaller s;
w1.installEventFilter(&s);
w2.connect(&s, SIGNAL(closing()), SLOT(close()));
return app.exec();
}
#include "main.moc"
#include <QtGui>
class EventSignaller : public QObject
{
Q_OBJECT
signals:
void closing();
protected:
bool eventFilter(QObject *object, QEvent *event)
{
if(event->type() == QEvent::Close)
emit(closing());
return QObject::eventFilter(object, event);
}
};
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
QWidget w1;
w1.setWindowTitle("w1");
w1.show();
QWidget w2;
w2.setWindowTitle("w2");
w2.show();
EventSignaller s;
w1.installEventFilter(&s);
w2.connect(&s, SIGNAL(closing()), SLOT(close()));
return app.exec();
}
#include "main.moc"
To copy to clipboard, switch view to plain text mode
Bookmarks