Loading... # 引言 不加图标太丑了,其实添加图标还算是挺容易的。 ![image.png](https://www.zunmx.top/usr/uploads/2023/05/48006260.png) # 实现 在pro文件中添加一行`RC_ICONS = icon.ico` 就可以了。 如 ```properties QT += core gui sql greaterThan(QT_MAJOR_VERSION, 4): QT += widgets CONFIG += c++17 # You can make your code fail to compile if it uses deprecated APIs. # In order to do so, uncomment the following line. #DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0 SOURCES += \ main.cpp \ mainwindow.cpp HEADERS += \ mainwindow.h \ FORMS += \ mainwindow.ui # Default rules for deployment. qnx: target.path = /tmp/$${TARGET}/bin else: unix:!android: target.path = /opt/$${TARGET}/bin !isEmpty(target.path): INSTALLS += target RC_ICONS = icon.ico DISTFILES += RESOURCES += \ resource.qrc ``` 此时目录结构是这样的 ![image.png](https://www.zunmx.top/usr/uploads/2023/05/2818908319.png) # 最终 最终生成的文件是这样的。 ![image.png](https://www.zunmx.top/usr/uploads/2023/05/546155633.png) © 允许规范转载 打赏 赞赏作者 支付宝微信 赞 如果觉得我的文章对你有用,请随意赞赏