QT生成ICO文件

生成ICO文件

cpp 复制代码
#include <QApplication>
#include <QImage>
#include <QIcon>
#include <QFile>
#include <QDebug>
#include <QPixmap>

int main(int argc, char* argv[])
{
    QApplication app(argc, argv);

    // 读取图片文件
    QImage image("D:\\MultiChannelVideo\\code\\src\\115_xviewer_test\\img\\logo_150_40.png"); // 替换为您的图片文件路径

    if (image.isNull()) {
        qDebug() << "Failed to load image.";
        return 1;
    }

    // 保存图像为.ico文件
    QString filePath = "D:\\MultiChannelVideo\\code\\src\\115_xviewer_test\\img\\output_icon.ico"; // 保存的.ico文件路径
    QPixmap pixmap = QPixmap::fromImage(image);
    if (pixmap.save(filePath, "ICO")) {
        qDebug() << "Icon saved to" << filePath;
    }
    else {
        qDebug() << "Failed to save icon.";
    }

    return app.exec();
}

相关推荐
范特西.i5 天前
QT聊天项目(8)
开发语言·qt
枫叶丹45 天前
【Qt开发】Qt界面优化(七)-> Qt样式表(QSS) 样式属性
c语言·开发语言·c++·qt
十五年专注C++开发5 天前
Qt deleteLater作用及源码分析
开发语言·c++·qt·qobject
kangzerun5 天前
SQLiteManager:一个优雅的Qt SQLite数据库操作类
数据库·qt·sqlite
金刚狼885 天前
qt和qt creator的下载安装
开发语言·qt
追烽少年x5 天前
Qt中使用Zint库显示二维码
qt
谁刺我心5 天前
qt源码、qt在线安装器镜像下载
开发语言·qt
金刚狼885 天前
在qt creator中创建helloworld程序并构建
开发语言·qt
扶尔魔ocy6 天前
【转载】QT使用linuxdeployqt打包
开发语言·qt
YxVoyager6 天前
在VS2017中使用Qt的foreach宏,IntelliSense无法正确识别函数定义
c++·qt