QT (c++语言) - Windows 添加图标

引言

不加图标太丑了,其实添加图标还算是挺容易的。
image.png

实现

在pro文件中添加一行RC_ICONS = icon.ico 就可以了。
如

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

最终

最终生成的文件是这样的。
image.png

评论 0

还没有评论,来说点什么吧。

提交后需要审核才会公开。