PDA

View Full Version : QtCreator, QPixmap & jpeg support



NinoUzi
26th June 2009, 22:56
I'm using Windows and trying to show jpeg image in QLabel, but it doesn't want to load it with QPixmap. I found some older threads which say I have to load jpeg plugin. I tried inserting "QTPLUGIN += qjpeg" into .pro file, adding "#include <QtPlugin>" with "plugin import" but no luck. After I add any of those, I get "collect ld" error from compiler. I thought it could be because Qt wasn't configured with "-qt-libjpeg", and after 2 hours of reconfigurin and compiling it wouldn't work anyway. Any help?

wysota
26th June 2009, 23:11
http://www.qtcentre.org/forum/faq.php?faq=qt_images#faq_qt_missing_images

NinoUzi
26th June 2009, 23:21
I can't compile with plugin support and without it fails to load jpeg with qpixmap.

wysota
27th June 2009, 12:21
I can't compile with plugin support
Why?


and without it fails to load jpeg with qpixmap.

You need the plugin either in its static or dynamic version.

NinoUzi
27th June 2009, 13:04
#include <QtCore/QtPlugin>

Q_IMPORT_PLUGIN(qjpeg);

->
release/main.o(.text+0x189):main.cpp: undefined reference to `qt_plugin_instance_qjpeg()'
collect2: ld returned 1 exit status

If I add QTPLUGIN += qjpeg into .pro file, I get this error:


F:\Qt\2009.02\mingw\bin\..\lib\gcc\mingw32\3.4.2\. .\..\..\..\mingw32\bin\ld.exe: cannot find -lqjpeg
collect2: ld returned 1 exit status

I also tried to remove all that code and put qjpeg4.dll into my executable folder (release), but still nothing loads

NinoUzi
27th June 2009, 15:35
I got it to work finally, I searched these forums a bit and found I have to put qjpeg4.dll into "imageformats" folder and not directly where my exe is.

wysota
27th June 2009, 18:38
I got it to work finally, I searched these forums a bit and found I have to put qjpeg4.dll into "imageformats" folder and not directly where my exe is.

It would be easier if you just read the text behind the link I gave you.

NinoUzi
27th June 2009, 19:15
"Why no images are displayed when I deploy my application on another machine that doesn't have Qt installed even though they are displayed on my computer?"

That wasn't my problem so I didn't think that fix would work. I didn't think it would require imageformats/ in Release/Debug path of project.

wysota
27th June 2009, 19:38
That wasn't my problem so I didn't think that fix would work. I didn't think it would require imageformats/ in Release/Debug path of project.

Sure it was :-)

And copying the plugins is not necessary, Qt looks for them in its standard paths therefore you had a non-standard installation of Qt (apart from the standard one you probably also had as I assume the plugins did reside in the imageformats subdirectory of the plugins directory of the installation).