[更新] 升级到python 2.7.6和Qt 4.8.7似乎会解决此问题,并提供JPEG支持。而在使用.jpeg / .jpg文件的路径创建QPixmap对象之前,会产生一个isNull()始终为True的对象,现在我得到一个有效的QPixmap对象。
有问题的平台是CentOS 7.2系统,KDE4作为默认桌面环境。 Qt 4.8.5与PySide 1.2.2一起安装。由于某种原因,似乎缺少JPEG支持。
>>> from PySide import QtGui
>>> pprint(QtGui.QImageReader.supportedImageForamts())
[PySide.QtCore.QByteArray('BW'),
PySide.QtCore.QByteArray('EPS'),
PySide.QtCore.QByteArray('EPSF'),
PySide.QtCore.QByteArray('EPSI'),
PySide.QtCore.QByteArray('EXR'),
PySide.QtCore.QByteArray('PCX'),
PySide.QtCore.QByteArray('PSD'),
PySide.QtCore.QByteArray('RAS'),
PySide.QtCore.QByteArray('RGB'),
PySide.QtCore.QByteArray('RGBA'),
PySide.QtCore.QByteArray('SGI'),
PySide.QtCore.QByteArray('TGA'),
PySide.QtCore.QByteArray('XCF'),
PySide.QtCore.QByteArray('bmp'),
PySide.QtCore.QByteArray('bw'),
PySide.QtCore.QByteArray('dds'),
PySide.QtCore.QByteArray('eps'),
PySide.QtCore.QByteArray('epsf'),
PySide.QtCore.QByteArray('epsi'),
PySide.QtCore.QByteArray('exr'),
PySide.QtCore.QByteArray('jp2'),
PySide.QtCore.QByteArray('pbm'),
PySide.QtCore.QByteArray('pcx'),
PySide.QtCore.QByteArray('pgm'),
PySide.QtCore.QByteArray('pic'),
PySide.QtCore.QByteArray('png'),
PySide.QtCore.QByteArray('ppm'),
PySide.QtCore.QByteArray('psd'),
PySide.QtCore.QByteArray('ras'),
PySide.QtCore.QByteArray('rgb'),
PySide.QtCore.QByteArray('rgba'),
PySide.QtCore.QByteArray('sgi'),
PySide.QtCore.QByteArray('tga'),
PySide.QtCore.QByteArray('xbm'),
PySide.QtCore.QByteArray('xcf'),
PySide.QtCore.QByteArray('xpm'),
PySide.QtCore.QByteArray('xv')]
如您所见,未列出任何JPEG支持。 Qt图像格式包含:
libqgif.so
libqico.so
libqjpeg.so
libqmng.so
libqsvg.so
libqtga.so
libqtiff.so
在libqjpeg.so上执行ldd会产生:
linux-vdso.so.1 => (0x00007ffc43530000)
libQtGui.so.4 => /lib64/libQtGui.so.4 (0x00007f2c11977000)
libQtCore.so.4 => /lib64/libQtCore.so.4 (0x00007f2c1148c000)
libpthread.so.0 => /lib64/libpthread.so.0 (0x00007f2c1126f000)
libstdc++.so.6 => /lib64/libstdc++.so.6 (0x00007f2c10f67000)
libm.so.6 => /lib64/libm.so.6 (0x00007f2c10c65000)
libgcc_s.so.1 => /lib64/libgcc_s.so.1 (0x00007f2c10a4e000)
libc.so.6 => /lib64/libc.so.6 (0x00007f2c1068d000)
libgthread-2.0.so.0 => /lib64/libgthread-2.0.so.0 (0x00007f2c1048b000)
libglib-2.0.so.0 => /lib64/libglib-2.0.so.0 (0x00007f2c10153000)
libpng15.so.15 => /lib64/libpng15.so.15 (0x00007f2c0ff28000)
libz.so.1 => /lib64/libz.so.1 (0x00007f2c0fd12000)
libfreetype.so.6 => /lib64/libfreetype.so.6 (0x00007f2c0fa6b000)
libgobject-2.0.so.0 => /lib64/libgobject-2.0.so.0 (0x00007f2c0f81b000)
libSM.so.6 => /lib64/libSM.so.6 (0x00007f2c0f613000)
libICE.so.6 => /lib64/libICE.so.6 (0x00007f2c0f3f6000)
libXi.so.6 => /lib64/libXi.so.6 (0x00007f2c0f1e6000)
libXrender.so.1 => /lib64/libXrender.so.1 (0x00007f2c0efdc000)
libXrandr.so.2 => /lib64/libXrandr.so.2 (0x00007f2c0edd1000)
libXfixes.so.3 => /lib64/libXfixes.so.3 (0x00007f2c0ebcb000)
libXcursor.so.1 => /lib64/libXcursor.so.1 (0x00007f2c0e9c0000)
libXinerama.so.1 => /lib64/libXinerama.so.1 (0x00007f2c0e7bc000)
libfontconfig.so.1 => /lib64/libfontconfig.so.1 (0x00007f2c0e580000)
libXext.so.6 => /lib64/libXext.so.6 (0x00007f2c0e36e000)
libX11.so.6 => /lib64/libX11.so.6 (0x00007f2c0e02f000)
libdl.so.2 => /lib64/libdl.so.2 (0x00007f2c0de2b000)
librt.so.1 => /lib64/librt.so.1 (0x00007f2c0dc23000)
/lib64/ld-linux-x86-64.so.2 (0x00007f2c128b9000)
libffi.so.6 => /lib64/libffi.so.6 (0x00007f2c0da1a000)
libuuid.so.1 => /lib64/libuuid.so.1 (0x00007f2c0d815000)
libexpat.so.1 => /lib64/libexpat.so.1 (0x00007f2c0d5ea000)
libxcb.so.1 => /lib64/libxcb.so.1 (0x00007f2c0d3c8000)
libXau.so.6 => /lib64/libXau.so.6 (0x00007f2c0d1c3000)
我看到没有丢失共享库,但也没有看起来像JPEG库。 QT_PLUGIN_PATH指向/ usr / lib64 / kde4 / plugins,/ usr / lib64 / kde4 / plugins / imageformats包含以下文件:
kimg_dds.so
kimg_eps.so
kimg_exr.so
kimg_jp2.so
kimg_pcs.so
kimg_pic.so
kimg_psd.so
kimg_ras.so
kimg_rgb.so
kimg_tga.so
kimg_xcf.so
kimg_xview.so
所以没有kimg_jpeg.so(如果有这样的事情),显然kimg_jp2.so不提供JPEG支持。那我错过了什么?