×

Discussion Board

Results 1 to 5 of 5
  1. #1
    Regular Contributor
    Join Date
    Dec 2010
    Posts
    228

    Question Restart an application

    Hi,

    I am facing a problem in closing some objects in my app.
    so I need to restart the application, or restart the main.
    i found the below code on the internet, but it didn't work well. it's giving me the following error :
    "no matching function for call to 'MainWindow::MainWindow(QPointer<QApplication>&)'

    the code is :

    #define RESTART_CODE 1000
    int main(int argc, char *argv[])
    {
    int return_from_event_loop_code;
    QPointer<QApplication> app;
    QPointer<MainWindow> main_window;
    do
    {
    if(app) delete app;
    if(main_window) delete main_window;

    app = new QApplication(argc, argv);
    main_window = new MainWindow(app);
    return_from_event_loop_code = app->exec();
    }
    while(return_from_event_loop_code==RESTART_CODE)

    return return_from_event_loop_code;
    }
    and to restart it, from the main window, i think i should call exit(1000)

    Any idea about the error ??? or is there another way to restart my application from the mainwindow???

    thanks you,
    best regards.

  2. #2
    Nokia Developer Moderator
    Join Date
    Oct 2009
    Location
    Finland
    Posts
    327

    Re: Restart an application

    The error is the result of how MainWindow was declared - whoever you copied the example from, added a QApplication-parametered constructor, as the default template doesn't do that (i.e. lose the app parameter and it will work). However, I doubt this is really going to solve any of the problems, even if it helps masking some of them - if you're leaking memory or having issues with destructors, deleting QApplication/MainWindow should make no difference.

  3. #3
    Regular Contributor
    Join Date
    Dec 2010
    Posts
    228

    Re: Restart an application

    Quote Originally Posted by achipa View Post
    The error is the result of how MainWindow was declared - whoever you copied the example from, added a QApplication-parametered constructor, as the default template doesn't do that (i.e. lose the app parameter and it will work). However, I doubt this is really going to solve any of the problems, even if it helps masking some of them - if you're leaking memory or having issues with destructors, deleting QApplication/MainWindow should make no difference.
    so how can i restart it ?
    i want to kill all the objects ( network things, like qnetworkrequest, qnetworkaccessmanager, QUdpSocket ) used in my mainwindow and recreate them another time.
    any other way ????

  4. #4
    Regular Contributor
    Join Date
    Dec 2010
    Posts
    228

    Re: Restart an application

    Quote Originally Posted by achipa View Post
    The error is the result of how MainWindow was declared - whoever you copied the example from, added a QApplication-parametered constructor, as the default template doesn't do that (i.e. lose the app parameter and it will work). However, I doubt this is really going to solve any of the problems, even if it helps masking some of them - if you're leaking memory or having issues with destructors, deleting QApplication/MainWindow should make no difference.
    i found another way to restart my app.
    thanks anyway

  5. #5
    Nokia Developer Moderator
    Join Date
    Oct 2009
    Location
    Finland
    Posts
    327

    Re: Restart an application

    Quote Originally Posted by Rondo23 View Post
    so how can i restart it ?
    i want to kill all the objects ( network things, like qnetworkrequest, qnetworkaccessmanager, QUdpSocket ) used in my mainwindow and recreate them another time.
    any other way ????
    I'm not sure why this would be a problem... What's wrong with a "delete qwhateverobject" followed by a "new qwhateverobject" ? Alternatively, if the things you want killed are QObjects, just tie a signal to their QObject::deleteLater() slot and then fire the signal whenever needed.

Similar Threads

  1. Restart Application
    By AmbikaSingh in forum Symbian User Interface
    Replies: 6
    Last Post: 2011-03-05, 14:03
  2. Restart Application!
    By amerzannouneh in forum Symbian C++
    Replies: 5
    Last Post: 2008-09-08, 03:38
  3. Application Restart
    By lucky@symbian in forum Symbian C++
    Replies: 5
    Last Post: 2007-11-02, 08:57
  4. auto restart application
    By nabaparna in forum Symbian C++
    Replies: 4
    Last Post: 2007-04-17, 19:46
  5. How to restart an application from itself ?
    By rdx83 in forum Symbian C++
    Replies: 1
    Last Post: 2004-10-10, 14:27

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •