Saving QPixmap to JPEG failing (Qt 4.5)

陌路散爱 提交于 2019-12-06 01:13:05

probably it cant find the plugin...

you can add library path to project or you can simply put imageformats folder near your binary.

imageformats folder is in plugins..

(probably you cant display jpeg images too)

If you are making a static build, you have to add QTPLUGIN += qjpeg to your .pro file, so that the static jpeg library of the imageformats is linked with your application.

Your plugin is most likely missing, best way to work is by only listing image formats that the toolkit supports.

This example is from my insert picture but you should be able to adapt it for your save as:

QString fileFormats = "(";
/* Get all inputformats */
for (int i = 0; i < QImageReader::supportedImageFormats().count(); i++) {
    fileFormats += "*."; /* Insert wildcard */
    fileFormats
            += QString(QImageReader::supportedImageFormats().at(i)).toLower(); /* Insert the format */
    fileFormats += " "; /* Insert a space */
}
fileFormats += ")";

QString fileName = QFileDialog::getOpenFileName(this, tr("Open Image"),
        currentPath, tr("Images ") + fileFormats);

Also we sometimes lose formats if a developer copies a debug build to a QA machine. The Debug version will be looking for the debug plugins and fail to load them.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!