Updater for Qt5, enabling application auto-updates.
MIT License
Updater for Qt5 (auto-updates).
This library contains:
QtUpdater
QtUpdateController
, that may be use with QtWidgets or QtQuick/QML.QtUpdateWidget
, that may be used as a QWidget
or inside a QDialog
.It provides these features:
temp
folder.Add the library as a dependency with CMake FetchContent.
include(FetchContent)
FetchContent_Declare(QtUpdater
GIT_REPOSITORY "https://github.com/oclero/qtupdater.git"
)
FetchContent_MakeAvailable(QtUpdater)
Link with the library in CMake.
target_link_libraries(your_project oclero::QtUpdater)
Include the only necessary header in your C++ file.
#include <oclero/QtUpdater.hpp>
The protocol is the following:
The client sends a request to the endpoint URL of your choice. Example (with curl):
curl http://server/endpoint?version=latest
The server answers by sending back an appcast: a JSON file containing the necessary information. The appcast must look like the following:
{
"version": "x.y.z",
"date": "dd/MM/YYYY",
"checksum": "418397de9ef332cd0e477ff5e8ca38d4",
"checksumType": "md5",
"installerUrl": "http://server/endpoint/package-name.exe",
"changelogUrl": "http://server/endpoint/changelog-name.md"
}
The client downloads the changelog from changelogUrl
, if any provided (facultative step).
The client downloads the installer from installerUrl
, if any provided.
The client installs the installer:
A very basic server written in Python is included as testing purposes. Don't use in production environment!
# Start with default config.
python examples/dev_server/main.py
# ... Or set your own config.
python examples/dev_server/main.py --dir /some-directory --port 8000 --address 127.0.0.1
Some examples of valid requests for this server:
# The client must be able to retrieve the latest version.
curl http://localhost:8000?version=latest
# This is equivalent to getting the latest version.
curl http://localhost:8000
# If the following version exist, the request is valid.
curl http://localhost:8000?version=1.2.3
# If the file exist, the request is valid.
curl http://localhost:8000/v1.1.0.exe
// Create an updater.
oclero::QtUpdater updater("https://server/endpoint");
// Subscribe to all necessary signals. See documentation for complete list.
QObject::connect(&updater, &oclero::QtUpdater::updateAvailabilityChanged,
&updater, [&updater]() {
if (updater.updateAvailability() == oclero::QtUpdater::UpdateAvailable::Available) {
qDebug() << "Update available! You have: "
<< qPrintable(updater.currentVersion())
<< " - Latest is: "
<< qPrintable(updater.latestVersion());
} else if (updater.updateAvailability() == oclero::QtUpdater::UpdateAvailable::UpToDate) {
qDebug() << "You have the latest version.";
} else {
qDebug() << "Error.";
}
});
// Start checking.
updater.checkForUpdate();
Olivier Cléro | email | website | github | gitlab
QtUpdater is available under the MIT license. See the LICENSE file for more info.