• 如何在Qt Creator中导入图标资源


    本文主要描述如何在Qt Creator中创建资源文件,并的打入导入图标文件。

    查看图标资源文件时,可以在项目的工程文件上鼠标单击右键-Open With-资源编辑器,效果如下图所示:

    在项目的工程文件上鼠标单击右键-Open With-普通文本编辑器,效果如下图所示:

    如果需要导入已经存在的资源文件和图标文件,如saribbonresouce.qrc是已经存在的资源文件,icon是已经存在的图标文件,见下图所示,

    如果需要导入已经存在的资源文件和图标文件,则只需要在项目的项目文件*.pro中最后添加如下蓝色标注的语句:

    #-------------------------------------------------
    #
    # Project created by QtCreator 2019-01-20T22:12:15
    #
    #-------------------------------------------------
    
    QT       += core gui
    
    greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
    
    TARGET = MyRibbonWindow
    TEMPLATE = app
    
    # The following define makes your compiler emit warnings if you use
    # any feature of Qt which has been marked as deprecated (the exact warnings
    # depend on your compiler). Please consult the documentation of the
    # deprecated API in order to know how to port your code away from it.
    DEFINES += QT_DEPRECATED_WARNINGS
    
    # You can also make your code fail to compile if you use deprecated APIs.
    # In order to do so, uncomment the following line.
    # You can also select to disable deprecated APIs only up to a certain version of Qt.
    #DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000    # disables all the APIs deprecated before Qt 6.0.0
    
    #配置本应用程序编译后的输出路径
    CONFIG(debug, debug|release){
        DESTDIR = $$PWD/../bin_qt$$[QT_VERSION]_debug
    }else {
        DESTDIR = $$PWD/../bin_qt$$[QT_VERSION]_release
    }
    
    SOURCES += 
            main.cpp 
            mainwindow.cpp
    
    HEADERS += 
            mainwindow.h
    
    FORMS += 
            mainwindow.ui
    
    RESOURCES += 
        saribbonresouce.qrc 
    
    #此处的$$PWD代表D:MyProjectMyRibbonDemoMyRibbonWindowMyRibbonWindow.pro文件所在的目录
    include($$PWD/../SARibbonBar.pri)

    之后,按下“Crtl+S”保存,Qt Creator就会自动扫描和导入图标资源。如果未自动加载,可将Qt Creator关闭后再重启,一般就可加载成功。

  • 相关阅读:
    Python命名规范 Test
    MySQL学习总结之路(第七章:选择合适的数据类型)
    MySQL 遇到错误以及解决
    MySQL学习 配置执行日志记录
    SpringCloud Alibaba整合Sentinel
    Java对姓名, 手机号, 身份证号, 地址进行脱敏
    JSP页面button标签的id与onclick函数名字相同导致函数失效的问题
    mysql游标的使用:对查询的结果进行遍历
    基于SpringBoot+redis如何实现一个点赞功能?
    byte与str的相互转换
  • 原文地址:https://www.cnblogs.com/rainbow70626/p/10298679.html
Copyright © 2020-2023  润新知