利用 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格式文件。也用上面的方式解決。