关于Qt的QPixmap中不支持jpg文件格式的问题

问题

Qt部分版本存在不支持jpg,JPEG等图像格式的问题
qDebug()<<QImageWriter::supportedImageFormats();
这行代码可以查看所支持的图像格式,我的是这样
在这里插入图片描述
可以看到支持的图片格式较少

解决方案

通过QApplication::addLibraryPath添加对其他图片格式的支持
在main函数中添加如下代码

//这里C:\\Qt\\5.15.2是我的安装目录
QApplication::addLibraryPath("C:\\Qt\\5.15.2\\mingw81_64\\plugins");

这个时候再查看supportedImageFormats()
qDebug()<<QImageWriter::supportedImageFormats();
在这里插入图片描述
支持的图片格式变多了

参考链接这里

posted @ 2022-11-15 20:56  DaoDao777999  阅读(228)  评论(0编辑  收藏  举报