├── QtReleaseExamples.jpg ├── QtShortcut ├── show.jpg ├── QtShortcut.pro └── main.cpp ├── QmlVersionInfo ├── logo.ico ├── show.jpg ├── qml.qrc ├── VersionInfo.qrc ├── QmlVersionInfo.pro ├── main.qml ├── main.cpp └── VersionInfo.rc ├── QtUninstallInfo ├── show.jpg ├── QtUninstallInfo.pro └── main.cpp ├── QtReleaseExamples.pro ├── .gitignore ├── LICENSE └── README.md /QtReleaseExamples.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhengtianzuo/QtReleaseExamples/HEAD/QtReleaseExamples.jpg -------------------------------------------------------------------------------- /QtShortcut/show.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhengtianzuo/QtReleaseExamples/HEAD/QtShortcut/show.jpg -------------------------------------------------------------------------------- /QmlVersionInfo/logo.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhengtianzuo/QtReleaseExamples/HEAD/QmlVersionInfo/logo.ico -------------------------------------------------------------------------------- /QmlVersionInfo/show.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhengtianzuo/QtReleaseExamples/HEAD/QmlVersionInfo/show.jpg -------------------------------------------------------------------------------- /QtUninstallInfo/show.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhengtianzuo/QtReleaseExamples/HEAD/QtUninstallInfo/show.jpg -------------------------------------------------------------------------------- /QmlVersionInfo/qml.qrc: -------------------------------------------------------------------------------- 1 | 2 | 3 | main.qml 4 | 5 | 6 | -------------------------------------------------------------------------------- /QmlVersionInfo/VersionInfo.qrc: -------------------------------------------------------------------------------- 1 | 2 | 3 | logo.ico 4 | VersionInfo.rc 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /QtReleaseExamples.pro: -------------------------------------------------------------------------------- 1 | #------------------------------------------------- 2 | # 3 | # Copyright (C) 2003-2103 CamelSoft Corporation 4 | # 5 | #------------------------------------------------- 6 | 7 | TEMPLATE = subdirs 8 | SUBDIRS += QmlVersionInfo 9 | SUBDIRS += QtUninstallInfo 10 | SUBDIRS += QtShortcut 11 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Prerequisites 2 | *.d 3 | *.user 4 | 5 | # Compiled Object files 6 | *.slo 7 | *.lo 8 | *.o 9 | *.obj 10 | 11 | # Precompiled Headers 12 | *.gch 13 | *.pch 14 | 15 | # Compiled Dynamic libraries 16 | 17 | # Fortran module files 18 | *.mod 19 | *.smod 20 | 21 | # Compiled Static libraries 22 | *.lai 23 | *.la 24 | *.a 25 | 26 | # Executables 27 | *.exe 28 | *.out 29 | *.app 30 | -------------------------------------------------------------------------------- /QtShortcut/QtShortcut.pro: -------------------------------------------------------------------------------- 1 | #------------------------------------------------- 2 | # 3 | # Copyright (C) 2003-2103 CamelSoft Corporation 4 | # 5 | #------------------------------------------------- 6 | 7 | QT += core 8 | 9 | QT -= gui 10 | 11 | CONFIG += c++11 12 | 13 | TARGET = QtUninstallInfo 14 | 15 | CONFIG += console 16 | 17 | CONFIG -= app_bundle 18 | 19 | TEMPLATE = app 20 | 21 | SOURCES += main.cpp 22 | -------------------------------------------------------------------------------- /QmlVersionInfo/QmlVersionInfo.pro: -------------------------------------------------------------------------------- 1 | #------------------------------------------------- 2 | # 3 | # Copyright (C) 2003-2103 CamelSoft Corporation 4 | # 5 | #------------------------------------------------- 6 | 7 | QT += qml quick webengine 8 | 9 | CONFIG += c++11 10 | 11 | SOURCES += main.cpp 12 | 13 | RESOURCES += qml.qrc 14 | 15 | win32{ 16 | RESOURCES += VersionInfo.qrc 17 | RC_FILE = VersionInfo.rc 18 | } 19 | -------------------------------------------------------------------------------- /QtUninstallInfo/QtUninstallInfo.pro: -------------------------------------------------------------------------------- 1 | #------------------------------------------------- 2 | # 3 | # Copyright (C) 2003-2103 CamelSoft Corporation 4 | # 5 | #------------------------------------------------- 6 | 7 | QT += core 8 | 9 | QT -= gui 10 | 11 | CONFIG += c++11 12 | 13 | TARGET = QtUninstallInfo 14 | 15 | CONFIG += console 16 | 17 | CONFIG -= app_bundle 18 | 19 | TEMPLATE = app 20 | 21 | SOURCES += main.cpp 22 | -------------------------------------------------------------------------------- /QmlVersionInfo/main.qml: -------------------------------------------------------------------------------- 1 | /*! 2 | *@file main.qml 3 | *@brief 主文件 4 | *@version 1.0 5 | *@section LICENSE Copyright (C) 2003-2103 CamelSoft Corporation 6 | *@author zhengtianzuo 7 | */ 8 | import QtQuick 2.7 9 | import QtQuick.Controls 2.0 10 | import QtWebEngine 1.4 11 | 12 | ApplicationWindow { 13 | visible: true 14 | width: 1024 15 | height: 768 16 | title: qsTr("Qml程序版本信息") 17 | 18 | WebEngineView{ 19 | id: webEngineView 20 | anchors.fill: parent 21 | url: "http://www.camelstudio.cn" 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /QmlVersionInfo/main.cpp: -------------------------------------------------------------------------------- 1 | /*! 2 | *@file main.cpp 3 | *@brief 程序主文件 4 | *@version 1.0 5 | *@section LICENSE Copyright (C) 2003-2103 CamelSoft Corporation 6 | *@author zhengtianzuo 7 | */ 8 | #include 9 | #include 10 | #include 11 | 12 | int main(int argc, char *argv[]) 13 | { 14 | QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling); 15 | QGuiApplication app(argc, argv); 16 | QtWebEngine::initialize(); 17 | 18 | QQmlApplicationEngine engine; 19 | engine.load(QUrl(QLatin1String("qrc:/main.qml"))); 20 | 21 | return app.exec(); 22 | } 23 | -------------------------------------------------------------------------------- /QtShortcut/main.cpp: -------------------------------------------------------------------------------- 1 | /*! 2 | *@file main.cpp 3 | *@brief 程序主文件 4 | *@version 1.0 5 | *@section LICENSE Copyright (C) 2003-2103 CamelSoft Corporation 6 | *@author zhengtianzuo 7 | */ 8 | #include 9 | #include 10 | #include 11 | #include 12 | 13 | int main(int argc, char *argv[]) 14 | { 15 | QCoreApplication a(argc, argv); 16 | 17 | //建立桌面快捷方式 18 | QString strAppPath = "C:/Windows/System32/notepad.exe"; 19 | QString strDesktopLink = QStandardPaths::writableLocation(QStandardPaths::DesktopLocation) + "/"; 20 | strDesktopLink += "notepad.lnk"; 21 | QFile fApp(strAppPath); 22 | fApp.link(strDesktopLink); 23 | 24 | //建立开始菜单快捷方式 25 | QString strMenuLink = QStandardPaths::writableLocation(QStandardPaths::ApplicationsLocation) + "/"; 26 | strMenuLink += "notepad/"; 27 | QDir pathDir; 28 | pathDir.mkpath(strMenuLink); 29 | strMenuLink += "notepad.lnk"; 30 | fApp.link(strMenuLink); 31 | return(0); 32 | } 33 | -------------------------------------------------------------------------------- /QmlVersionInfo/VersionInfo.rc: -------------------------------------------------------------------------------- 1 | #include "winver.h" 2 | 3 | IDI_ICON1 ICON DISCARDABLE "logo.ico" 4 | 5 | VS_VERSION_INFO VERSIONINFO 6 | FILEVERSION 1,0,0,0 7 | PRODUCTVERSION 1,0,0,0 8 | FILEFLAGS 0x0L 9 | FILEFLAGSMASK 0x3fL 10 | FILEOS 0x00040004L 11 | FILETYPE 0x1L 12 | FILESUBTYPE 0x0L 13 | BEGIN 14 | BLOCK "StringFileInfo" 15 | BEGIN 16 | BLOCK "080404b0" 17 | BEGIN 18 | VALUE "CompanyName", "zhengtianzuo" 19 | VALUE "FileDescription", "QmlVersionInfo" 20 | VALUE "FileVersion", "1.0.0.0" 21 | VALUE "InternalName", "QmlVersionInfo.exe" 22 | VALUE "LegalCopyright", "Copyright (C) 2003-2103 CamelSoft Corporation" 23 | VALUE "OriginalFilename","QmlVersionInfo.exe" 24 | VALUE "ProductName", "QmlVersionInfo" 25 | VALUE "ProductVersion", "1.0.0.0" 26 | END 27 | END 28 | BLOCK "VarFileInfo" 29 | BEGIN 30 | VALUE "Translation", 0x0804, 1200 31 | END 32 | END 33 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2017 zhengtianzuo 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | 2 | ![](https://github.com/zhengtianzuo/QtReleaseExamples/blob/master/QtReleaseExamples.jpg?raw=true) 3 | 4 | # QtReleaseExamples 5 | Qt 发布相关的技术分享 6 | 7 | ![](https://img.shields.io/badge/%E7%89%88%E6%9D%83%E8%AE%B8%E5%8F%AF-MIT-orange.svg) 8 | ![](https://img.shields.io/badge/Qt-5.10-blue.svg) 9 | ![](https://img.shields.io/badge/VS-2017-blue.svg) 10 | ![](https://img.shields.io/badge/%E7%89%88%E6%9C%AC-1.0.0.0-blue.svg) 11 | ![](https://img.shields.io/badge/%E7%BC%96%E8%AF%91-%E6%88%90%E5%8A%9F-brightgreen.svg) 12 | 13 | QmlVersionInfo: Qml程序版本信息 14 | 15 | ![](https://github.com/zhengtianzuo/QtReleaseExamples/blob/master/QmlVersionInfo/show.jpg?raw=true) 16 | 17 | 18 | QtUninstallInfo: Qt写入卸载信息 19 | 20 | ![](https://github.com/zhengtianzuo/QtReleaseExamples/blob/master/QtUninstallInfo/show.jpg?raw=true) 21 | 22 | 23 | QtShortcut: Qt创建桌面和开始菜单快捷方式 24 | 25 | ![](https://github.com/zhengtianzuo/QtReleaseExamples/blob/master/QtShortcut/show.jpg?raw=true) 26 | 27 | 28 | 29 | 30 | #### 联系方式: 31 | *** 32 | |作者|郑天佐| 33 | |---|--- 34 | |QQ|278969898 35 | |主页|http://www.camelstudio.cn/ 36 | |邮箱|camelsoft@163.com 37 | |博客|http://blog.csdn.net/zhengtianzuo06/ 38 | |github|https://github.com/zhengtianzuo 39 | |QQ群|199672080 ![](https://github.com/zhengtianzuo/zhengtianzuo.github.io/blob/master/qqgroup.jpg?raw=true) 40 | 41 | 42 | 43 | ###### 觉得分享的内容还不错, 就请作者喝杯咖啡吧~~ 44 | *** -------------------------------------------------------------------------------- /QtUninstallInfo/main.cpp: -------------------------------------------------------------------------------- 1 | /*! 2 | *@file main.cpp 3 | *@brief 程序主文件 4 | *@version 1.0 5 | *@section LICENSE Copyright (C) 2003-2103 CamelSoft Corporation 6 | *@author zhengtianzuo 7 | */ 8 | #include 9 | #include 10 | 11 | //!@brief 注册表字段 12 | #ifdef Q_OS_WIN32 13 | const QString strUninstall = 14 | "HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\"; 15 | const QString strPublisher = "Publisher"; 16 | const QString strDisplayName = "DisplayName"; 17 | const QString strDisplayIcon = "DisplayIcon"; 18 | const QString strDisplayVersion = "DisplayVersion"; 19 | const QString strInstallLocation = "InstallLocation"; 20 | const QString strUninstallString = "UninstallString"; 21 | #endif 22 | 23 | //获取注册表 24 | QString getRegValue( 25 | QString &strPath, QString strItemName) 26 | { 27 | QSettings reg(strPath, QSettings::NativeFormat); 28 | return (reg.value(strItemName).toString()); 29 | } 30 | 31 | //写入注册表 32 | void setRegValue( 33 | QString strPath, QString strItemName, QString strItemData) 34 | { 35 | QSettings reg(strPath, QSettings::NativeFormat); 36 | reg.setValue(strItemName, strItemData); 37 | } 38 | 39 | //删除注册表 40 | void delRegValue( 41 | QString strPath, QString strItemName) 42 | { 43 | QSettings reg(strPath, QSettings::NativeFormat); 44 | if (strItemName != nullptr) 45 | { 46 | reg.remove(strItemName); 47 | } 48 | else 49 | { 50 | reg.remove(strPath); 51 | } 52 | } 53 | 54 | int main(int argc, char *argv[]) 55 | { 56 | QCoreApplication a(argc, argv); 57 | 58 | QString strAppPath = "MyApp"; 59 | QString strAppName = QStringLiteral("这是程序的名称"); 60 | QString strAppIcon = "C:/Windows/System32/notepad.exe"; 61 | QString strAppVersion = "v1.0.0.0"; 62 | 63 | //写入卸载信息 64 | QString strUninstall(strUninstall); 65 | strUninstall += strAppPath; 66 | setRegValue(strUninstall, strDisplayName, strAppName); 67 | setRegValue(strUninstall, strDisplayIcon, strAppIcon); 68 | setRegValue(strUninstall, strDisplayVersion, strAppVersion); 69 | setRegValue(strUninstall, strPublisher, "zhengtianzuo"); 70 | setRegValue(strUninstall, strUninstallString, strAppIcon); 71 | 72 | return(0); 73 | } 74 | --------------------------------------------------------------------------------