I am working on linux. I wrote a small Qt application that itself should install the new version of application (software update). and On click of restart button from Ui should restart with updated version.
For that, I am applying the below logic :
QDir sourceDir("/Desktop/FileTransferDemo");
QDir currentDir(QDir::currentPath());
QProcess copying;
QStringList arg;
arg.append(sourceDir.filePath("CopyAndRestore_v2"));
arg.append(currentDir.path());
copying.start("cp",arg);
if (copying.waitForFinished(12000) == true)
{
if (copying.exitCode() == 0)
{
}
}
QFile app(currentDir.filePath("CopyAndRestore"));
app.remove();
QFile newApp(currentDir.filePath("CopyAndRestore_v2"));
newApp.rename("CopyAndRestore");
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:
on_restartButton_clicked()
{
QProcess::startDetached(QCoreApplication::applicationFilePath());
qApp->quit();
}
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.
I would suggest the following procedure:
-> You are running an updated version of the file.
(I think the Qt Maintenance Tool does it exactly like that)