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

相关推荐
kupeThinkPoem1 小时前
QJsonObject能否嵌套查找?
qt·json
Henry Zhu1231 小时前
Qt样式系统详解(下)
qt
hqwest2 小时前
码上通QT实战10--监控页面02-绘制温度盘
开发语言·qt·自定义控件·qwidget·提升部件·qt绘图
cn_mengbei3 小时前
鸿蒙PC开发实战:Qt环境搭建保姆级教程与常见问题避坑指南(HarmonyOS 4.0+DevEco Studio 3.1最新版)
qt·华为·harmonyos
非凡ghost3 小时前
MPC-QT视频播放器(基于Qt框架播放器)
开发语言·windows·qt·音视频·软件需求
cn_mengbei3 小时前
从零到一:基于Qt on HarmonyOS的鸿蒙PC原生应用开发实战与性能优化指南
qt·性能优化·harmonyos
IOT-Power5 小时前
QT 对话框(QDialog)中 accept、reject、exec、open的使用
开发语言·qt
_OP_CHEN6 小时前
【从零开始的Qt开发指南】(十九)Qt 文件操作:从 I/O 设备到文件信息,一站式掌握跨平台文件处理
开发语言·c++·qt·前端开发·文件操作·gui开发·qt文件
cn_mengbei7 小时前
鸿蒙PC开发指南:从零配置Qt环境到实战部署完整流程
qt·华为·harmonyos
GREGGXU7 小时前
Could not load the Qt platform plugin “xcb“ in ““ even though it was found.
linux·qt