I wrote this to prevent the user from closing the main dialog and leaving other windows open:

Qt Code:
  1. void Dialog::closeEvent(QCloseEvent *e) {
  2. if (QMessageBox::question(this, tr("Close ALL windows?"),
  3. tr("Close ALL windows?"), QMessageBox::Yes, QMessageBox::No) == QMessageBox::Yes)
  4. {
  5. qApp->closeAllWindows();
  6. }
  7. }
To copy to clipboard, switch view to plain text mode 

But when I click yes nothing happens and the program is blocked.
What I do wrong?