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:
{
ui->setupUi(this);
this->actualizarInterfaz();
}
void wMain::actualizarInterfaz()
{
DAO* aDao = new DAO("");
this->asg = aDao->Query(1);
delete aDao;
if(this->asg != NULL)
{
// populate gui with data recovered
}
else
{
this,
"Error",
"...");
qApp->exit(1);
}
}
wMain::wMain(QWidget *parent) : QWidget(parent), ui(new Ui::wMain)
{
ui->setupUi(this);
this->actualizarInterfaz();
}
void wMain::actualizarInterfaz()
{
DAO* aDao = new DAO("");
this->asg = aDao->Query(1);
delete aDao;
if(this->asg != NULL)
{
// populate gui with data recovered
}
else
{
QMessageBox::critical(
this,
"Error",
"...");
qApp->exit(1);
}
}
To copy to clipboard, switch view to plain text mode
How could I fix this? There are another ways to do it?
Bookmarks