It seems that when I implement the QMainWindow::closeEvent() function, my application blocks shutdown -ie, when I shutdown the computer, it tries to close all the apps but chokes on my Qt app, and so it doesn't shut down. In my closeEvent() function I do create a QMessageBox to ask the user if it's okay to exit. When I remove this QMessageBox out, my app closes on shutdown correctly along with the rest of system. Wondering what might be wrong with my code...

Qt Code:
  1. mpMessageBox = new QMessageBox(QMessageBox::Question, "Name",
  2. QString(tr("Are you sure you want to exit?")),
  3. QMessageBox::Yes | QMessageBox::No, this);
  4. mpMessageBox->setModal(true);
  5. mpMessageBox->setAttribute(Qt::WA_DeleteOnClose);
  6. mpMessageBox->show();
  7. connect(mpMessageBox, SIGNAL(destroyed()), this, SLOT(dismissMsgBox()));
To copy to clipboard, switch view to plain text mode 

Yes, I know it's rather unorthodox to create a message box like this, but it was just so that it would not block the event loop, while still having a modal dialog.