The application does not restart on the device. In Qt

I am developing a Qt symbian application in which I have to restart the application in my application, used:

qApp->quit();
QProcess::startDetached(qApp->arguments()[0],qApp->arguments());

from a method in mainWindow. It works fine on the simulator, but not on the device, it closes, but does not restart on its own, I have to restart it myself, is there anything else I have to do to make it work on the device.

+3
source share
3 answers

One solution would be to create a small console process that you can start from your main program before closing it. Then this console process will simply launch your program and close. I use such processes to track my applications and restart them if they crash.

+2

, : Symbian , . , , - API. , iPhone . , Symbian API ARM WINS. , , .

Symbian ( , - KExitException), Active Scheduler, . , , . quit, startProcess, . , , startProcess, quit: , , (GUI) . startProcess, , .

, @Riho. quit, . SwEvent .

+1

I tried it with Qprocess () and it seems to work fine (still testing memory and thread issues)

in main.cpp I am writing this code (which I got from another link)

int main(int argc, char *argv[])
{
    #define RESTART_CODE 1000

    int return_from_event_loop_code;
    QPointer<QApplication> app;
    QPointer<MainWindow> main_window;
    do
    {
        if(main_window) delete main_window;
        if(app) delete app;

        app = new QApplication(argc, argv);
        main_window = new MainWindow;
        QList<QString> lang = AppStatus::getCurrentLanguage();
        QTranslator translator;
        translator.load(lang.at(0));
        app->installTranslator(&translator);
        main_window->setOrientation(MainWindow::ScreenOrientationLockPortrait);


#if defined(Q_OS_SYMBIAN)
        main_window->showMaximized();
#else
        main_window->show();
#endif

        return_from_event_loop_code = app->exec();
    }
    while(return_from_event_loop_code==RESTART_CODE);

    return return_from_event_loop_code;
}

and in my method, where should I restart the application, I wrote this.

QProcess::startDetached(qApp->applicationFilePath(),qApp->arguments());
qApp->exit(RESTART_CODE);

And my application restarts as I wanted. If any changes are nedded plese let me know.

0
source

All Articles