Qt安装程序框架:自动更新 [英] Qt Installer Framework: Auto Update
问题描述
我目前正在使用Qt安装程序框架,并设法建立了一个在线存储库.我想知道的是:
I'm currently using the Qt Installer Framework and managed to set up an online repository. What I want to know is:
框架是否提供某种自动更新"机制,例如每次程序/系统启动时都会检查更新的插件/服务吗?
检查更新就足够了,因为安装本身可以使用维护工具完成.
Does the Framework provide some kind of "auto-update" mechanism, e.g. a plugin/service that checks for updates every time the program/system starts?
Check for updates would be enough, since the installation itself can be done using the maintanance tool.
关于这个主题,我所能找到的只是这句话:
All I could find about this topic was this small sentence:
最终用户可以在初始安装后使用维护工具从服务器安装其他组件,以及在服务器上发布更新后接收自动更新.
从这里
: http://doc.qt.io/qtinstallerframework/ifw-overview.html#choosing-installer-type
感谢您的帮助!
修改:建议
基于这个问题的被接受者,我创建了一个小型库,可以使用安装程序框架自动检查更新- https://github. com/Skycoder42/QtAutoUpdater
Suggestion
Based on this question's accepted answere I created a small library to automatically check for updates using the installer framework - https://github.com/Skycoder42/QtAutoUpdater
推荐答案
我要做的是使用QProcess运行维护工具,然后检查输出.它具有一种模式,其中它不运行GUI,而仅输出更新信息(如果可用).
What I do, is run the maintenance tool using QProcess, and then check the output. It has a mode where it doesn't run the GUI but only outputs update information if available.
请注意,在应用程序启动时,我将工作目录设置为应用程序的路径,因此我可以运行maintenancetool.
Note that I set the working directory to the application's path when the applications starts, so I can just run maintenancetool.
QProcess process;
process.start("maintenancetool --checkupdates");
// Wait until the update tool is finished
process.waitForFinished();
if(process.error() != QProcess::UnknownError)
{
qDebug() << "Error checking for updates";
return false;
}
// Read the output
QByteArray data = process.readAllStandardOutput();
// No output means no updates available
// Note that the exit code will also be 1, but we don't use that
// Also note that we should parse the output instead of just checking if it is empty if we want specific update info
if(data.isEmpty())
{
qDebug() << "No updates available";
return false;
}
// Call the maintenance tool binary
// Note: we start it detached because this application need to close for the update
QStringList args("--updater");
bool success = QProcess::startDetached("maintenancetool", args);
// Close the application
qApp->closeAllWindows();
这篇关于Qt安装程序框架:自动更新的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!