Results 1 to 12 of 12

Thread: Restart Qt Application

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Restart Qt Application

    Quote Originally Posted by sh_erfan View Post
    If so, how can I restart completely??
    You return from main().

    Restart either via a script or a helper program that runs this application.

    Cheers,
    _

  2. The following user says thank you to anda_skoa for this useful post:

    sh_erfan (16th August 2015)

  3. #2
    Join Date
    Aug 2015
    Posts
    8
    Thanks
    6
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: Restart Qt Application

    Quote Originally Posted by anda_skoa View Post
    You return from main().

    Restart either via a script or a helper program that runs this application.

    Cheers,
    _
    Helper will work.
    Good idea.
    But i must know why page loading is incomplete in my webview.

  4. #3
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: Restart Qt Application

    I don't see what you are trying to achieve by this loop and application exit call that could not be achieved by simply clearing any cookies/local storage. Calling exit() possibly has side effects.

    Persisting down your path, try this:
    • Remove the use of exit()
    • Provide your main window class with a boolean member, m_reloadMe, and a public getter
    • Set the m_reloadMe and call close() instead of (ab)using exit()
    • Make your main():
    Qt Code:
    1. include "mainwindow.h"
    2. #include <QApplication>
    3.  
    4. int main(int argc, char *argv[])
    5. {
    6. QApplication a(argc, argv);
    7. int code = 0;
    8. bool goAgain(false);
    9. do
    10. {
    11. MainWindow w;
    12. w.show();
    13. code = a.exec();
    14. goAgain = w.reloadMe()
    15. }while(goAgain);
    16. return code;
    17. }
    To copy to clipboard, switch view to plain text mode 


    Your on_load_complete() slot is probably connected twice; once by you, and once by the auto connection mechanism.
    Your code will probably misbehave if either site redirects and the loaded url is not the same as the requested url.

  5. #4
    Join Date
    Aug 2015
    Posts
    8
    Thanks
    6
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: Restart Qt Application

    Hi all
    My problem solved with reseting the cookies of my browser, So I dont nedd to restart the application.
    Qt Code:
    1. ui->webView->page()->networkAccessManager()->setCookieJar(new QNetworkCookieJar());
    To copy to clipboard, switch view to plain text mode 
    @ChrisW67 : I wrote the way you said, but no changes have occured. QwebView becomes lazy and not acting properly. I will post the solution if I find it some day.
    Thanks to all.

Similar Threads

  1. How to restart an application
    By Naami in forum Qt Programming
    Replies: 11
    Last Post: 21st January 2015, 15:47
  2. Replies: 0
    Last Post: 14th December 2010, 00:39
  3. Restart Application
    By d4rc in forum Newbie
    Replies: 8
    Last Post: 13th May 2010, 14:24
  4. How to restart an application?
    By xylosper in forum Qt Programming
    Replies: 2
    Last Post: 12th August 2007, 13:04
  5. Restart QApplication
    By Svaths in forum Qt for Embedded and Mobile
    Replies: 5
    Last Post: 8th February 2007, 11:54

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Qt is a trademark of The Qt Company.