1

I have wrote an app in Qt and C++.

the main contain is calling a MainUi class and in case of issue during the Main UI init, the MainUi class is calling the QApplication::exit(). The Application seems close at first but the icon is still present in the dock which mean that the application is not really quit.

Here is the code used by the class MainUI.

void MainUI::InitResult() {
    if(error != ERROR_NONE) {
        QApplication::processEvents();
        Splashscreen->Ui_Splashscreen_failure();
        Timer timer(4000);
        Splashscreen->close();
        emit error_init();
    }
    else
    {
        QApplication::processEvents();
        Puls_Splashscreen->close();
        QApplication::setOrganizationName(COMPANY_NAME);
        QApplication::setApplicationName(PRODUCT_NAME);
        InitUserInterface();
    }
}

the main.cpp is managing to instantiate the MainUI class but do not have any close()/quit() action

MainUI MyWindow(*DeviceFramework);
QObject::connect(&MyWindow, SIGNAL(error_init()),&app, SLOT(quit()));
MyWindow.InitApplication();
return app.exec();

InitApplication is enabling the management. At the end of the treatment the MainUI receive a signal and the slot InitResult() to treat the error. I have created another signal init_error() which is emitted by InitResult() to inform about an issue and ask to close the app.

Any idea ?

Seb
  • 2,929
  • 4
  • 30
  • 73
  • 1
    The problem is probably in calling `QApplication::exit()` **before** the `QApplication::exec()` is called. – vahancho May 28 '15 at 06:19

0 Answers0