因为我们要把写好的程序发给用户来用,写好的源码也不方便给别人看,所以要把程序进行打包部署。
步骤一:点击左下角的电脑图标将 Debug 模式切换到 Release 模式。

release 模式:发布版本,不对源代码进行调试,基本没有调试信息。
debug 模式:调试版本,有很多调试信息。
步骤二:找到 release 模式构建的文件夹。

步骤三:修改可执行程序图标。先把图标加到工程所在文件夹。然后在 pro 文件里面添加
RC_ICONS=serial_iocn.ico
注意:图标的格式必须为.ico 这个格式的,其他格式不行。

步骤四:封包操作。需要用到 QT 的控制台,点击电脑左下角,在搜素栏搜索 qt,即可看到 qt 控制台,
双击即可打开,如下图 :


我们需要电脑桌面上创建一个新的文件夹,注意千万不要有中文路径。然后把 exe 文件拷贝到我们新
创建的文件夹里面,在控制台进入可执行文件所在的目录,如图:

步骤五:使用 windeployqt 工具把库加到我们新创建的这个文件夹里面。
格式:windeployqt exe 文件的名称,如图:

打包成功后,进入执行文件路径,双击程序就可以打开,如图:

|