#include 赞 踩 #include "SoftWareUpdate.h" QProcess restartP; } int main(int argc, char *argv[]) QApplication a(argc, argv); int x = deskTopWidget.width()/2; w.setFixedWidth(700); w.setGeometry(x-350,y-100,700,300); // when restart check , whether updater need update std::thread t(updaterUpdate); // do update return a.exec(); Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。
qt 进程 线程 detach --- 无限重启程序_startdeched会一直执行qt
#include <QApplication>
#include <QDesktopWidget>
// when need updater update
void updaterUpdate()
{
sleep(5);
// QProcess p;
//p.startDetached("killall updater");
// p.waitForStarted(2);
//sleep(2);
QStringList extrFileList;
extrFileList.append("updater");
JlCompress::extractFiles("../WorkSpace.zip",extrFileList,"./");
sleep(2);
restartP.startDetached("./updater");
{
SoftWareUpdate w;
QDesktopWidget deskTopWidget;
int y = deskTopWidget.height()/2;
w.setFixedHeight(300);
w.show();
if(w.isUpdaterExist("../","WorkSpace.zip")){
t.detach();
}
w.updaterTask();
}