Как обновить исполнительный файл в qt c++ посредством перезапуска программы
вот предоставляю код
void MainWindow::restartLauncher()
{
QString appDirPath = QCoreApplication::applicationDirPath();
QString newLauncherPath = appDirPath + "/new_mainwindow.exe";
QString currentLauncherPath = appDirPath + "/mainwindow.exe";
qApp->quit();
QCoreApplication::processEvents();
QCoreApplication::exit();
QFile file("mainwindow.exe");
file.remove();
if (QFile::rename(newLauncherPath, currentLauncherPath))
{
QProcess::startDetached(currentLauncherPath);
}
else
{
QMessageBox::critical(this, "Error", "Failed to replace launcher file. Please check the files.");
}
}
Источник: Stack Overflow на русском