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();
}

相关推荐
xcyxiner14 小时前
DicomViewer (目录调整) 2
qt
xcyxiner16 小时前
dcmtk vtk vtk-dicom(gdcm) 编译(debug) v2
qt
桥田智能3 天前
桥田智能 QT-650S:面向白车身焊装的 800kg 重载快换解决方案
开发语言·qt·系统架构
森G3 天前
75、服务器源码解析---------云视频服务项目
linux·服务器·网络·c++·qt
森G3 天前
77、线程池原理和实现------服务器源码解析----云视频服务项目
服务器·c++·qt
森G3 天前
71、打包发布---------打包发布
c++·qt
初圣魔门首席弟子3 天前
Node.js 详细介绍(知识库版)
windows·qt·node.js·知识库
C++ 老炮儿的技术栈3 天前
Qt工控实战:自研机器人TCP长连接客户端(粘包处理+心跳保活+自动重连完整源码解析)
qt·tcp/ip·机器人
郝学胜-神的一滴3 天前
CMake 019:程序生成与清理全解析
开发语言·c++·qt·程序人生·软件构建·cmake
森G3 天前
76、仿ASIO实现的Linux c++服务器------服务器源码解析----云视频服务项目
c++·qt