欢迎访问 生活随笔!

生活随笔

当前位置: 首页 > 前端技术 > HTML >内容正文

HTML

qt 利用 HTML 生成PDF文档,不能显示jpg图片

发布时间:2025/3/15 HTML 17 豆豆
生活随笔 收集整理的这篇文章主要介绍了 qt 利用 HTML 生成PDF文档,不能显示jpg图片 小编觉得挺不错的,现在分享给大家,帮大家做个参考.

 

利用 QPrinter 和html 生成 pdf文档

其中用html语句有显示图片的语句

但只能显示png格式的图片,不能显示jpg格式图片。

经过排查:语法,文件路径等都正确,最终在stack overflow 中找到 原因:在执行程序中没有安装 jpg图形格式的plugin

https://stackoverflow.com/questions/14878670/qt-does-not-load-jpg-just-png

{

Your executable is missing the jpg plugin. Optional means, that if your executable doesn't find the plugins (dlls) it will start, but without loading these image formats. It is the same with a lot of qt features (fe: slqdrivers)

You will find the folder "imageformats" in C:\Qt\4.8.4\plugins (replace your installation dir and version), copy it to your executable path and it will show jpgs.

Probably, some environmental variables of your colleagues differ a bit from yours.

Take care with Qt plugins and the distribution of your application.

}

 

同样 在qlistwiget中以图标方式显示图片时也不能显示jpg格式文件。也用上面的方式解决。

 

转载于:https://www.cnblogs.com/keleman/p/7715849.html

总结

以上是生活随笔为你收集整理的qt 利用 HTML 生成PDF文档,不能显示jpg图片的全部内容,希望文章能够帮你解决所遇到的问题。

如果觉得生活随笔网站内容还不错,欢迎将生活随笔推荐给好友。