On my application I try to retrieve data from a database. If this step is succesfull the application continues, Instead I want that the application shows a QMessage::critical(...) and closes with QApplication::exit(). The error appears but the application dosn't stops. The code is:

Qt Code:
  1. wMain::wMain(QWidget *parent) : QWidget(parent), ui(new Ui::wMain)
  2. {
  3. ui->setupUi(this);
  4. this->actualizarInterfaz();
  5. }
  6.  
  7. void wMain::actualizarInterfaz()
  8. {
  9. DAO* aDao = new DAO("");
  10. this->asg = aDao->Query(1);
  11. delete aDao;
  12.  
  13. if(this->asg != NULL)
  14. {
  15. // populate gui with data recovered
  16. }
  17. else
  18. {
  19. QMessageBox::critical(
  20. this,
  21. "Error",
  22. "...");
  23. qApp->exit(1);
  24. }
  25. }
To copy to clipboard, switch view to plain text mode 

How could I fix this? There are another ways to do it?