Qjpeg plugin not loaded; cannot call setPixmap() on a QLabel() with a JPG image
-
I am trying to have a QLabel() display a pixmap JPG image from a file (which can't be in a resource file since it is downloaded from the web), but I am having problems loading it. The code is fairly simple:
@label = QLabel()
label.setPixmap(QPixmap("image.jpg"))@It works with PNG files, but it doesn't work with JPG files. I have Googled quite a bit and found that I needed to place the "imageformats" folder in the same folder where my script is located. However, even after doing this (and yes, qjpeg4.dll and others are there), it still doesn't work. I've also tried doing
@path = r"C:\Users\Deusdies\Documents\Work\myapp\imageformats"
app.addLibraryPath(path)@but that didn't help either.
Again, it loads PNGs just fine, but it won't load JPGs. I've also noticed even before that it won't load ICO either, but I thought of it as an unrelated issue - however it doesn't seem that way now.
It is worth noting that the application is not converted to an .exe at this point - it is ran through python.exe interpreter via PowerShell.
If I do this:
@QtGui.QImageReader.supportedImageFormats()@
I get this:
@[PySide.QtCore.QByteArray('bmp'), PySide.QtCore.QByteArray('pbm'), PySide.QtCore.QByteArray('pgm'), PySide.QtCore.QByteArray('png'), PySide.QtCore.QByteArray('ppm'), PySide.QtCore.QByteArray('xbm'), PySide.QtCore.QByteArray('xpm')]@
Obviously JPG is not included - so the question basically is how to include jpg in this?
My development environment is Windows 7 x64, PySide 1.1.0
How can I solve this problem?
-
Remove imageformats from following path.
@
path = r"C:\Users\Deusdies\Documents\Work\myapp\imageformats"
app.addLibraryPath(path)
@The plugin path is PluginPath/imageformats/qjpeg4.dll
Or you can simple move the imageformats/qjpeg4.dll to where your application located, for example
@
python27.exe [or your own xxxx.exe]
imageformats/qjpeg4.dll
@ -
Okay so if I understood you correctly...
I tried changing path to
@path = r"C:\Users\Deusdies\Documents\Work\myapp"@ (this folder has the imageformats folder in it, with all the plugins.)
and to
@path = r"C:\Users\Deusdies\Documents\Work\myapp\imageformats\qjpeg4.dll"@
Neither of which solutions worked. The .py file that I am executing is in the "myapp" folder.
Regards
-
[quote author="Deusdies" date="1337887611"]Okay so if I understood you correctly...
I tried changing path to
@path = r"C:\Users\Deusdies\Documents\Work\myapp"@ (this folder has the imageformats folder in it, with all the plugins.)
and to
@path = r"C:\Users\Deusdies\Documents\Work\myapp\imageformats\qjpeg4.dll"@
[/quote]The formal is right, it will work if you qjpeg4.dll is copied form the right place. Make sure this if more or that one Qt libraries exist in your system.
The later is always wrong.
[quote author="Deusdies" date="1337887611"]
Neither of which solutions worked. The .py file that I am executing is in the "myapp" folder.
Regards[/quote]It does't matter where your .py/.pyw files located. what matters is where your executable program (XXXX.exe) located if you want to avoid addLibraryPath().
-
Thanks! I realized that the reason it didn't work with the former path was because I created an instance of the QDialog class before the app.addLibraryPath() method was called! Problem solved!