Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8084999
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T17:58:09+00:00 2026-06-05T17:58:09+00:00

After a successful update, I am using the following logic to restart the application:

  • 0

After a successful update, I am using the following logic to restart the application:

   QString appName = QApplication::instance()->applicationName();
   QString appDir =  QApplication::instance()->applicationFilePath();
   QStringList arguments = QApplication::instance()->arguments();

   QProcess::startDetached( appName, arguments, appDir );

   //quit the current application
   QApplication::instance()->exit();

It starts the new application and also exits both the application. From Qt, I understand that the new process would live even after exiting the calling process. Am I missing something here?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T17:58:12+00:00Added an answer on June 5, 2026 at 5:58 pm

    Here are the problems:

    1. Your appName is not guaranteed not to be empty, and it’s not guaranteed to be same as the name of the executable. In any case, startDetached() expects a full path to the executable.

    2. Your appDir isn’t — it’s the full file path of the executable.

    3. The last argument to startDetached() is the working directory. You can simply use QDir::currentPath() for that.

    4. All of the QApplication methods that you are calling are static. You don’t need to use the instance().

    To update your application, you could:

    1. Rename the currently running executable to some other name.

    2. Write the new executable under the original name.

    3. Start as as below.

    This would work on both Windows and Unices, as long as your application had sufficient administrative rights — usually it won’t, though, so you need a separate updater with sufficient access rights. The updater would need to signal the application to restart itself at user’s convenience. It’s probably not very nice to forcibly restart the application while the user is busy using it.

    Below is a working example:

    #include <QtWidgets>
    
    void start() {
        auto app = QCoreApplication::applicationFilePath();
        auto arguments = QCoreApplication::arguments();
        auto pwd = QDir::currentPath();
        qDebug() << app << arguments << pwd;
        QProcess::startDetached(app, arguments, pwd);
        QCoreApplication::exit();
    }
    
    int main(int argc, char **argv) {
        QApplication app{argc, argv};
        QPushButton button{QStringLiteral("Spawn")};
        Starter starter;
        QObject::connect(&button, &QPushButton::clicked, &start);
        button.show();
        app.exec();
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm writing a simple app with AppEngine, using Python. After a successful insert by
I'm using flickr-fu gem within a rails application for flickr api integration. I'm following
I've been trying to query an email address using the following statement, however after
After successful setup on initial launch of MySQL, the page prompted me to set
Currently after successful login I add md5($username) md5($password) in cookies and then every time
Hi I have a Sticky form that after successful completion I want to clear
i need to know how to get success message after successful execution of sql
After a successful login via Devise, how can I redirect the user back to
After a successful start of Tomcat and a few REST calls I get this
I have no idea why the result array is empty after a successful ajax

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.