QSimpleUpdater

1.下载

  https://github.com/alex-spataru/QSimpleUpdater

2.功能

  下载.json,比较版本,版本更新下载、安装。

3.使用

  .h

1 QSimpleUpdater *m_updater;

  .cpp

复制代码
 1     m_updater = QSimpleUpdater::getInstance();
 2 
 3     /* Check for updates when the "Check For Updates" button is clicked */
 4     connect(m_updater, SIGNAL(checkingFinished(QString)), this, SLOT(updateChangelog(QString)));
 5     connect(m_updater, SIGNAL(appcastDownloaded(QString, QByteArray)), this, SLOT(displayAppcast(QString, QByteArray)));
 6 
 7     m_updater->setModuleVersion(DEFS_URL, "0.1");
 8     m_updater->setNotifyOnFinish(DEFS_URL, true);//发送checkingFinished信号
 9     m_updater->setNotifyOnUpdate(DEFS_URL, true);
10     m_updater->setUseCustomAppcast(DEFS_URL, false); //发送appcastDownloaded信号
11     m_updater->setDownloaderEnabled(DEFS_URL, true);
12     m_updater->setMandatoryUpdate(DEFS_URL, false);//强制更新
13 
14     /* Check for updates */
15     m_updater->checkForUpdates(DEFS_URL);
复制代码
复制代码
 1 void QtWidgetsApplication16::updateChangelog(const QString &url)
 2 {
 3     if (url == DEFS_URL)
 4         ui.textEdit->append(m_updater->getChangelog(url));
 5 }
 6 void QtWidgetsApplication16::displayAppcast(const QString &url, const QByteArray &reply)
 7 {
 8     if (url == DEFS_URL)
 9     {
10         QString text = "This is the downloaded appcast: <p><pre>" + QString::fromUtf8(reply)
11             + "</pre></p><p> If you need to store more information on the "
12             "appcast (or use another format), just use the "
13             "<b>QSimpleUpdater::setCustomAppcast()</b> function. "
14             "It allows your application to interpret the appcast "
15             "using your code and not QSU's code.</p>";
16 
17         ui.textEdit->append(text);
18     }
19 }
复制代码

  updates.json

复制代码
 1 {
 2   "updates": {
 3     "windows": {
 4       "open-url": "",
 5       "latest-version": "1.0",
 6       "download-url": "http://123.57.19.140:9008/智慧牧场客户端1.5.exe",
 7       "changelog": "",
 8       "mandatory": true
 9     },
10     "osx": {
11       "open-url": "",
12       "latest-version": "1.0",
13       "download-url": "https://raw.githubusercontent.com/alex-spataru/QSimpleUpdater/master/tutorial/download/YesItWorks.jpg",
14       "changelog": "This is an example changelog for Mac OS X. Go on...",
15       "mandatory": true
16     },
17     "linux": {
18       "open-url": "",
19       "latest-version": "1.0",
20       "download-url": "https://raw.githubusercontent.com/alex-spataru/QSimpleUpdater/master/tutorial/download/YesItWorks.jpg",
21       "changelog": "This is an example changelog for Linux. Go on...",
22       "mandatory": true
23     },
24     "ios": {
25       "open-url": "",
26       "latest-version": "1.0",
27       "download-url": "https://raw.githubusercontent.com/alex-spataru/QSimpleUpdater/master/tutorial/download/YesItWorks.jpg",
28       "changelog": "This is an example changelog for iOS. Go on...",
29       "mandatory": true
30     },
31     "android": {
32       "open-url": "",
33       "latest-version": "1.0",
34       "download-url": "https://raw.githubusercontent.com/alex-spataru/QSimpleUpdater/master/tutorial/download/YesItWorks.jpg",
35       "changelog": "This is an example changelog for Android. Go on...",
36       "mandatory": true
37     }
38   }
39 }
复制代码

 

posted @   wuyuan2011woaini  阅读(272)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· 10年+ .NET Coder 心语 ── 封装的思维:从隐藏、稳定开始理解其本质意义
· 提示词工程——AI应用必不可少的技术
· 地球OL攻略 —— 某应届生求职总结
· 字符编码:从基础到乱码解决
· SpringCloud带你走进微服务的世界
历史上的今天:
2022-03-14 nats-py
点击右上角即可分享
微信分享提示