Results 1 to 2 of 2

Thread: Restart app does not work

  1. #1
    Join Date
    Feb 2014
    Posts
    94
    Thanks
    5
    Qt products
    Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default Restart app does not work

    Hello!

    I am trying to restart my app using the code:
    Qt Code:
    1. QStringList args = QApplication::arguments();
    2. args.removeFirst();
    3. QProcess::startDetached(QApplication::applicationFilePath(), args);
    To copy to clipboard, switch view to plain text mode 
    or
    Qt Code:
    1. QProcess::startDetached(qApp->arguments()[0], qApp->arguments());
    2. qApp->quit();
    To copy to clipboard, switch view to plain text mode 

    It works fine when I run it in Qt, but when I build it, generate the .pkg and install it does not restart and when I reopen the app it gives a message that the app was finished during windows reopen.

    I am using OSX 10.9

    Thanks very much.

  2. #2
    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 app does not work

    What platform? Have you read the platform specific parts of the docs for arguments() and startDetached()?
    Does startDetached() return true or false?
    Is applicationFilePath() returning what you expect?
    Is the first element of arguments() the program name you expect?

Similar Threads

  1. How to restart an application
    By Naami in forum Qt Programming
    Replies: 11
    Last Post: 21st January 2015, 15:47
  2. Restart Application
    By d4rc in forum Newbie
    Replies: 8
    Last Post: 13th May 2010, 14:24
  3. how to restart the MainWindow?
    By d@nyal in forum Newbie
    Replies: 2
    Last Post: 3rd May 2010, 03:51
  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

Tags for this Thread

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
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.