qt程序打包发布

qt程序打包发布

目标: 我想安装自己开发的程序

1.打包依赖库

a.使用qtcreator编译生成程序demo.exe,这是一个release版的

b.在程序demo.exe目录打开cmd

c.输入命令

C:\Qt\Qt5.10.1\5.10.1\mingw53_32\bin\windeployqt.exe demo.exe --qmldir C:\Qt\Qt5.10.1\5.10.1\mingw53_32\qml

d.这样demo.exe运行依赖的库都会自动拷贝到同目录

2.Qt Installer Framework

a.去官网下载工具 http://download.qt.io/development_releases/installer-framework/3.0.1/installer-framework-build-stripped-3.0.1-win-x86.7z

b.解压到C:\Qt\ifw-pkg,examples目录是例子

c.把之前得到的demo.exe同目录下所有文件拷贝到
C:\Qt\ifw-pkg\examples\tutorial\packages\com.vendor.product\data,
data目录存放的是将来安装程序时候要释放安装的程序数据

d.在C:\Qt\ifw-pkg\examples\tutorial目录打开cmd

e.输入命令,创建离线安装包

C:\Qt\ifw-pkg\bin\binarycreator.exe --offline-only -t C:\Qt\ifw-pkg\bin\installerbase.exe -c config\config.xml -p packages demo.exe

f.这样就在tutorial目录生成安装包demo.exe

3.测试安装包

a.运行demo.exe

b.像一般软件那样下一步进行安装

c.安装完成后在C:\Users\chen\InstallationDirectory目录会看到安装结果

d.InstallationDirectory目录的maintenancetool.exe是维护工具,demo.exe就是我们的程序

详情参考官网 https://doc.qt.io/qtinstallerframework/index.html

4.希望安装程序后在开始菜单添加快捷方式

a.修改tutorial\packages\com.vendor.product\meta\installscript.qs文件

Component.prototype.createOperations = function()
{
    try {
        // call the base create operations function
        component.createOperations();
		if (systemInfo.productType === "windows") {
			component.addOperation("CreateShortcut", "@TargetDir@/demo.exe", "@StartMenuDir@/Love.lnk",
				"workingDirectory=@TargetDir@", "iconPath=@TargetDir@/demo.exe",
				"iconId=0", "description=Open Love file");
		}
    } catch (e) {
        console.log(e);
    }
}

b.重新生成安装包,安装

5.源代码参考

https://gitee.com/chen227/qmlMouseMove

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值