PDA

View Full Version : Qt4 does not load JPG's.



Teuniz
3rd September 2007, 09:52
I configured Qt 4.3.1 for X11 on OpenSUSE 10.2 as follows:

./configure -static -release -no-qt3support -qt-zlib -qt-gif -qt-libpng -qt-libmng -qt-libjpeg -qt-libtiff -nomake demos -nomake examples -nomake tools

make

su
make install

Everything works nice, except that I can not load JPG pictures:

mypixmap->load(":/images/picture.jpg");

It returns FALSE.

when I try this with a PNG picture (same resolution) it works.

What is missing to load JPG's? I configured with -qt-libjpeg.

wysota
3rd September 2007, 11:04
You have to import a static plugin into your application using Q_IMPORT_PLUGIN(qjpeg) macro. See docs for details.

Teuniz
3rd September 2007, 14:20
You have to import a static plugin into your application using Q_IMPORT_PLUGIN(qjpeg) macro. See docs for details.

Isn't it possible to link static to the jpeg lib?

Why this difference between png and jpg? I mean, why does it load png files
without a plugin?

wysota
4th September 2007, 00:06
Linking statically to the jpeg library (or rather the Qt plugin that links to libjpeg) is not enough. The application needs to be informed about the plugin - that's what the Q_IMPORT_PLUGIN macro is for.

PNG file support is embedded directly into Qt, without any plugins - that's why you can always load PNG or XPM images. This is not the case with JPEG or GIF. Reasons? As for GIF, surely the patent thing... As for JPEG? I don't know... ask Trolltech.