The Qt auto updater library is a library to automatically check for updates and install them. This repository includes:
Here some sample screenshots of the gui (The rocket of the information dialog is the "application icon" and depends on your application)
Dialog Sample | Windows | Mac | X11 |
---|---|---|---|
Progress Dialog | |||
Information Dialog | |||
Update Button | |||
Update Action |
There are multiple ways to install the Qt module, sorted by preference:
/path/to/MaintenanceTool --addTempRepository <url>
with one of the following urls (GUI-Method is currently broken, see QTIFW-1156) - This must be done every time you start the tool:
Qt > Qt 5.11 > Skycoder42 Qt modules
)Qt Auto Updater
qmake
make qmake_all
make
make install
The autoupdater is provided as a Qt module. Thus, all you have to do is add the module, and then, in your project, add QT += autoupdatercore
or QT += autoupdatergui
to your .pro file - depending on what you need!
The usage of this library is not that complicated. However, to make this work you will have to use the Qt Installer Framework to create an installer/updater. If you already know how to to that, just check out the examples below. If not, here are some links that will explain how to create an online-installer using the framework. Once you have figured out how to do that, it's only a small step to the updater library:
Important:
Since this library requires the maintenancetool that is deployed with every Qt Installer Framework installation, the examples cannot be tested without a maintenancetool! If you intend to use this library, the maintenancetool will be available for your final application. For testing purpose or the examples, I set the path to the MaintenanceTool
that is deployed with the installation of Qt (or any other maintenancetool). So make shure to adjust the path if you try to run the examples.
The following example shows the basic usage of the updater. Only the core library is required for this example. It creates a new updater instance that is connected to the maintenancetool located at "C:/Qt/MaintenanceTool". As soon as the application starts, it will check for updates and print the update result. If updates are available, their details will be printed and the maintenancetool is scheduled to start on exit. In both cases, the application will quit afterwards.
#include <QCoreApplication>
#include <QDebug>
#include <updater.h>
int main(int argc, char *argv[])
{
QCoreApplication a(argc, argv);
//create the updater with the application as parent -> will live long enough start the tool on exit
QtAutoUpdater::Updater *updater = new QtAutoUpdater::Updater("C:/Qt/MaintenanceTool", &a);//.exe is automatically added
QObject::connect(updater, &QtAutoUpdater::Updater::checkUpdatesDone, [updater](bool hasUpdate, bool hasError) {
qDebug() << "Has updates:" << hasUpdate << "\nHas errors:" << hasError;
if(hasUpdate) {
//As soon as the application quits, the maintenancetool will be started in update mode
updater->runUpdaterOnExit();
qDebug() << "Update info:" << updater->updateInfo();
}
//Quit the application
qApp->quit();
});
//start the update check
updater->checkForUpdates();
return a.exec();
}
This example will show you the full dialog flow of the controller. Both libraries are required for this example. Since there is no mainwindow in this example, you will only see the controller dialogs. Please note that you can control how much of that dialogset will be shown to the user. This example is reduced! for a full example with all parts of the controller, check the examples/autoupdatergui/WidgetsUpdater
application.
#include <QApplication>
#include <updatecontroller.h>
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
//Since there is no mainwindow, the various dialogs should not quit the app
QApplication::setQuitOnLastWindowClosed(false);
//create the update controller with the application as parent -> will live long enough start the tool on exit
//since there is no parent window, all dialogs will be top-level windows
QtAutoUpdater::UpdateController *controller = new QtAutoUpdater::UpdateController("C:/Qt/MaintenanceTool", &a);//.exe is automatically added
QObject::connect(updater, &QtAutoUpdater::UpdateController::runningChanged, [updater](bool running) {
qDebug() << "Running changed:" << running;
//quit the application as soon as the updating finished
if(!running)
qApp->quit();
});
//start the update check -> AskLevel to give the user maximum control
controller->start(QtAutoUpdater::UpdateController::AskLevel);
return a.exec();
}
The documentation is available on github pages. It was created using doxygen. The HTML-documentation and Qt-Help files are shipped together with the module for both the custom repository and the package on the release page. Please note that doxygen docs do not perfectly integrate with QtCreator/QtAssistant.
The core library does not need any translation, because it won't show anything to the user. The Gui library however does. The project is prepared for translation. Only german and spanish translations are provided. However, you can easily create the translations yourself. The file src/autoupdatergui/translations/QtAutoUpdaterController_template.ts
is a ready-made TS file. Just rename it (e.g. to QtAutoUpdaterController_jp.ts
) and open it with the QtLinguist to create the translations.
Most icons have been found using IconArchive
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。