Qt6.2 CLion CMake 应用程序打包发布并添加图标
1.新建rc文件
文件位置:(文件名字随便起怎么高兴怎么来!)
2.在文件中添加以下内容
路径为qrc中为.ico文件安排的路径
IDI_ICON1 ICON DISCARDABLE "icon/settings.ico"
附上我的qrc文件:
<RCC> <qresource prefix="prefix"> <file>resources/icon/new.png</file> <file>resources/icon/about.png</file> <file>resources/icon/export.png</file> <file>resources/icon/import.png</file> <file>resources/icon/save.png</file> <file>resources/icon/open.png</file> <file>resources/icon/settings.ico</file> </qresource> <qresource prefix="qss"> <file>resources/Aqua.qss</file> </qresource> </RCC>
3.CMakeList.txt中加入:(就是刚刚添加的rc文件名称)
set(app_icon_resource_windows "${CMAKE_CURRENT_SOURCE_DIR}/resources/photosurface.rc")
4.在之后的添加可执行文件处添加上 ${app_icon_resource_windows}
add_executable(AnalyseScd WIN32 tinyxml2.cpp tinyxml2.h main.cpp UI/MainWindow/mainwindow.cpp UI/MainWindow/mainwindow.h UI/MainWindow/mainwindow.ui DataAnalyse/dataanalyse.cpp Global/FileGlobal.cpp Global/FileGlobal.h Dao/DataTypeTemplates.h Dao/Communication.h Dao/IED.h Dao/IED.h test.h Plugins/pluginmanager.h Plugins/pluginmanager.cpp Plugins/TestPlugin.cpp Dao/Substation.h Dao/Header.h Dao/SCL.h Plugins/TestPlugin.h Plugins/Interface.h DataAnalyse/dataanalyse.h UI/ChildWnd/mychildwnd.cpp UI/ChildWnd/mychildwnd.h UI/ChildWnd/mychildwnd.ui UI/CIDout/cid.cpp UI/CIDout/cid.h UI/CIDout/cid.ui DataAnalyse/cidOut.cpp DataAnalyse/cidOut.h UI/CIDin/ui_wizard.h UI/CIDin/wizard.ui UI/CIDin/wizard.h UI/CIDin/wizard.cpp UI/CIDin/Page/InitPage/initpage.cpp UI/CIDin/Page/InitPage/initpage.h UI/CIDin/Page/InitPage/initpage.ui UI/CIDin/Page/chooseFilePath/choosefile.cpp UI/CIDin/Page/chooseFilePath/choosefile.h UI/CIDin/Page/chooseFilePath/choosefile.ui UI/CIDin/Page/showDifference/showdifference.cpp UI/CIDin/Page/showDifference/showdifference.h UI/CIDin/Page/showDifference/showdifference.ui UI/CIDin/Page/updateCommunication/updatacommunication.cpp UI/CIDin/Page/updateCommunication/updatacommunication.h UI/CIDin/Page/updateCommunication/updatacommunication.ui UI/CIDin/Page/showDifference/showDiffButtonWidget/showdiffbuttonwidget.cpp UI/CIDin/Page/showDifference/showDiffButtonWidget/showdiffbuttonwidget.h UI/CIDin/Page/showDifference/showDiffButtonWidget/showdiffbuttonwidget.ui UI/CIDin/Page/Finish/finish.cpp UI/CIDin/Page/Finish/finish.h UI/CIDin/Page/Finish/finish.ui UI/CIDin/wizardGlobal.h UI/CIDin/wizardGlobal.cpp UI/CIDin/Page/showDifference/showdifference.cpp UI/CIDin/Page/showDifference/showdifference.h UI/CIDin/Page/showDifference/showdifference.ui UI/ChildWnd/subWindow.h ${QRC_SOURCE_FILE} ${QM_FILES} ${app_icon_resource_windows} UI/MainWindow/Setting/setting.cpp UI/MainWindow/Setting/setting.h UI/MainWindow/Setting/setting.ui)
在图片的这里
5.之后重新进行打包操作即可
我使用的是NSIS 以及HM NIS Edit
参考:Qt 助手
分类:
Qt
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 被坑几百块钱后,我竟然真的恢复了删除的微信聊天记录!
· 没有Manus邀请码?试试免邀请码的MGX或者开源的OpenManus吧
· 【自荐】一款简洁、开源的在线白板工具 Drawnix
· 园子的第一款AI主题卫衣上架——"HELLO! HOW CAN I ASSIST YOU TODAY
· Docker 太简单,K8s 太复杂?w7panel 让容器管理更轻松!