Nominate our 2022 Qt Champions!

Restart Application with Updated Executable.

  • Hi,
    I am new to Qt. I wrote a small application that should update itself with the click of the restart button.
    For that, I am applying the below logic :

    QDir sourceDir("/Desktop/FileTransferDemo");
    QDir currentDir(QDir::currentPath());
    QProcess copying;
    QStringList arg;
    if (copying.waitForFinished(12000) == true)
    if (copying.exitCode() == 0)
    QFile app(currentDir.filePath("CopyAndRestore"));
    QFile newApp(currentDir.filePath("CopyAndRestore_v2"));

    i.e . copying new exe at the same path remove old exe and rename the new.
    here CopyAndRestore is my old exe and CopyAndRestore_v2 is the new one.
    After renaming the new exe and on click of restart button with below code:


    I am expecting the application should restart with new version. Bt it is not restarting.
    is this approach correct? Please suggest the solution for the expected output.

  • Lifetime Qt Champion

    Hi and welcome to devnet,

    Manipulating running executable is not something that is that easy especially on Windows. You might want to consider something like the Qt Installer Framework to manage that part.

  • Hi thanks for replying. I am working on linux.
    I gone through the framework installer and got idea that it is creating installer for application.
    But in my case I expect my application itself should install the new version(software update). I am not getting how to proceed on that .
    If possible will you please elaborate how can I use mentioned solution in my case?

  • Lifetime Qt Champion

    Did you check that everything is properly in place ?
    That you pass a valid path to startDetached ?

Log in to reply