You simply can connect the buttonClicked
signal (should be declared) of the Third object's button with the quit()
slot of the Second widget:
Second::createThird()
{
[..]
Third *third = new Third;
connect(third, SIGNAL(buttonClicked()), this, SLOT(quit());
[..]
}
You can emit buttonClicked()
signal when you click on the button, or do that in your Third widget's Third::closeEvent(QCloseEvent *)
virtual function's implmentation:
Third::closeEvent(QCloseEvent *event)
{
emit buttonClicked();
QWidget::closeEvent(event);
}