#include "Update.h" #include "Worker.h" #include #include Update::Update(QWidget *parent):QWidget(parent) { ui.setupUi(this); Worker* worker = new Worker(); connect(worker,&Worker::signalProgress,this,&Update::slotUpdateProgress); connect(worker,&Worker::sigShowStatus,this,&Update::slotUpdateInfo); connect(worker, &Worker::signalFinished, this, &Update::slotFinished); worker->start(); } Update::~Update() { } // 更新进度 void Update::slotUpdateProgress(qintptr progress, qintptr max) { qDebug() << "更新进度"; if (progress > 0 && max > 0) { qDebug() << "设置进度:" << progress << "|" << max; ui.progressBar->setMaximum(max); ui.progressBar->setValue(progress); if (progress == max) { slotFinished(); } } } // 完成更新 void Update::slotFinished() { QMessageBox::information(NULL, "提示", "更新完成!"); exit(1); // 启动主程序 // 关闭更新程序自身 } void Update::slotUpdateInfo(QString info) { ui.versionInfo->append(info); }