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

相关推荐
奇树谦2 天前
Qt Quick 图片加载与 GPU 纹理机制详解:QImage、QQuickTextureFactory、QSGTexture 与异步加载
开发语言·qt·系统架构
BroNekoX2 天前
我将基于 QtQuick 框架开发的音乐播放器性能做到顶级
qt
小小晓.3 天前
Qt 对话框、QLineEdit 与布局管理实战详解
开发语言·qt
扶尔魔ocy3 天前
【QT入门到晋级】用开源的自定义控件开发
c++·qt·自定义控件
lhbweilai4 天前
QT项目(串口助手)
开发语言·qt
小鱼仙官4 天前
Qt 主界面弹出分界面
开发语言·qt
誰能久伴不乏4 天前
用 UDP 做一条“可靠“的控制通道
c++·qt·网络协议·udp
Bczheng15 天前
VS2022 安装MFC和QT
c++·qt·mfc
会编程的小孩5 天前
8.19号函数
qt
蓝祁子yoky6 天前
Qt学习日记 Day15:网络编程(二)- UDP基础
网络·qt·学习