关于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();
支持的图片格式变多了
参考链接这里