This is what I wanted to do: a MainWindow launcher screen which, from a pushButton click event, goes hidden, shows MainWindow2, then when MainWindow2 is closed, is visible again.

This is what I expected to do:

Qt Code:
  1. void MainWindow::on_pushButton_clicked()
  2. {
  3. MainWindow2 *w = new MainWindow2(this);
  4. connect(w, SIGNAL(destroyed()), this, SLOT(show()));
  5. this->hide();
  6. w->show();
  7. }
To copy to clipboard, switch view to plain text mode 

Alas, closing MainWindow2 actually closes the entire application. I ended up having to override MainWindow2's closingEvent to do this:

Qt Code:
  1. void MainWindow2::closeEvent(QCloseEvent *event)
  2. {
  3. if (this->parentWidget() != 0)
  4. {
  5. this->parentWidget()->show();
  6. }
  7.  
  8. event->accept();
  9. }
To copy to clipboard, switch view to plain text mode 

This feels like a hack to me because logically I feel the application should never close as long as I never close the parent. Am I doing this wrong?