PDA

View Full Version : QPixmap bug under Qt4.3.1 ?



Nyphel
7th October 2007, 13:13
Hello,

I use Qt 4.3.1 OpenSource Edition on Windows XP Pro SP2 32bits.
My application has an interface with a QLabel.
My objective is to post an image, also I display it in the QLabel using a QPixmap.



int hauteur_jaquette = (tree->height ()) /2; // 50% of the height of the interface

QPixmap jaquette_pixmap;
jaquette_pixmap.load (acces_jaquette); // Loading of the image in QPixmap
jaquette_pixmap = jaquette_pixmap.scaledToHeight (hauteur_jaquette, Qt:: SmoothTransformation); // Scaling the image

label_jaquette->setPixmap (jaquette_pixmap); // Posting of QPixmap (and thus of the image) in the QLabel of the interface

That functions perfectly with the version OpenSource of Qt distribuated by Trolltech.
However, if I reconfigure Qt in static mode (configures static, make sub-src) and if I recompile my project, then the image is not displayed any more…

Would somebody have an idea, a council, a suggestion ?

jpn
7th October 2007, 13:18
And the image is in which format? Try PNG..?

Nyphel
7th October 2007, 13:31
The image is downloaded from the web before to be displayed, so it's generally .jpg and sometimes .gif ;)

So I don't know if I can convert it to .png from my application, but I'll test some .png images to understand well the problem.

Thanks for this tip :)

jpn
7th October 2007, 13:45
First of all, make sure your Qt was built with GIF and JPG support (configure script outputs detailed information about this, after qmake has been compiled, before reading all the .pro files). Secondly, since you're using static Qt, you will have to import static plugins:

.pro:

QTPLUGIN += qjpeg
main.cpp:

Q_IMPORT_PLUGIN(qjpeg)

More info: http://doc.trolltech.com/latest/qtplugin.html#Q_IMPORT_PLUGIN

Nyphel
7th October 2007, 14:16
Thanks !

So, if I understood well, I've to re-configure Qt with the following options :
-relase
-static
-qt-libgif
-qt-libpng (instead of the default option : -system-libpng)
-qt-libjpeg (instead of the default option : -system-libjpeg)

Next, I'll add "Q_IMPORT_PLUGIN(qjpeg)" (without ";" ?) at the top of my class .cpp and "QTPLUGIN += qgif qpng qjpeg" in my .pro file.

That's right ?

Nyphel
7th October 2007, 15:29
I've re-configured and re-built (make sub-src) my Qt4.3.1 OpenSource edition for Windows with the options that were listed above.
I got no errors, no warning.

Here is my .pro file :


TEMPLATE = app
TARGET = Listeur
QT += core \
gui \
network
HEADERS += Thread_existing_files.h \
Thread_HTTP_VC.h \
Thread_HTTP_MC.h \
Thread_HTTP_AC.h \
Thread_HTTP_QLCS.h \
Listeur.h \
Thread_scanneur.h \
donnee.h \
interface.h \
interface_impl.h
SOURCES += Thread_existing_files.cpp \
Thread_HTTP_VC.cpp \
Thread_HTTP_MC.cpp \
Thread_HTTP_AC.cpp \
Thread_HTTP_QLCS.cpp \
Listeur.cpp \
Thread_scanneur.cpp \
donnee.cpp \
interface_impl.cpp \
main.cpp
FORMS += interface.ui
QTPLUGIN += qgif \
qjpeg


Here is my main.cpp :


#include "Listeur.h"

#include <QtPlugin>
Q_IMPORT_PLUGIN(qjpeg)
Q_IMPORT_PLUGIN(qgif)

int main(int argc, char *argv[])
{
QApplication app(argc, argv);

Listeur * mon_listeur = new Listeur();

return app.exec();
}


When I build my application, using "qmake" an "make", I get the following error message :


D:\Applications\Qt\4.3.1\Workspace\Listeur>qmake

D:\Applications\Qt\4.3.1\Workspace\Listeur>make
mingw32-make -f Makefile.Release
mingw32-make[1]: Entering directory `D:/Applications/Qt/4.3.1/Workspace/Listeur'

g++ -c -O2 -Wall -fno-exceptions -fno-rtti -DUNICODE -DQT_LARGEFILE_SUPPORT -DQT
_NO_DEBUG -DQT_GUI_LIB -DQT_NETWORK_LIB -DQT_CORE_LIB -DQT_THREAD_SUPPORT -DQT_N
EEDS_QMAIN -I"..\..\include\QtCore" -I"..\..\include\QtCore" -I"..\..\include\Qt
Network" -I"..\..\include\QtNetwork" -I"..\..\include\QtGui" -I"..\..\include\Qt
Gui" -I"..\..\include" -I"..\..\include\ActiveQt" -I"tmp\moc\release_static" -I"
." -I"..\..\mkspecs\win32-g++" -o tmp\obj\release_static\main.o main.cpp
main.cpp: In function `int qMain(int, char**)':
main.cpp:15: warning: unused variable 'mon_listeur'
g++ -enable-stdcall-fixup -Wl,-enable-auto-import -Wl,-enable-runtime-pseudo-rel
oc -Wl,-s -Wl,-subsystem,windows -o "release\Listeur.exe" object_script.Listeur.
Release -L"d:\Applications\Qt\4.3.1\lib" -L"d:\Applications\Qt\4.3.1\lib" -lmin
gw32 -lqtmain -LD:/Applications/Qt/4.3.1/plugins/imageformats/ -lqgif4 -LD:/Appl
ications/Qt/4.3.1/plugins/imageformats/ -lqjpeg4 -lQtGui -lQtNetwork -lgdi32 -lc
omdlg32 -loleaut32 -limm32 -lwinmm -lwinspool -lmsimg32 -lQtCore -lkernel32 -lus
er32 -lshell32 -luuid -lole32 -ladvapi32 -lws2_32
./tmp\obj\release_static\main.o(.text+0x83):main.cpp : undefined reference to `qt
_plugin_instance_qjpeg()'
./tmp\obj\release_static\main.o(.text+0xa3):main.cpp : undefined reference to `qt
_plugin_instance_qgif()'
collect2: ld returned 1 exit status
mingw32-make[1]: *** [release\Listeur.exe] Error 1
mingw32-make[1]: Leaving directory `D:/Applications/Qt/4.3.1/Workspace/Listeur'
mingw32-make: *** [release] Error 2

D:\Applications\Qt\4.3.1\Workspace\Listeur>


I don't understand how to solve this linking error :s

jpn
7th October 2007, 15:30
-qt-libjpeg (instead of the default option : -system-libjpeg)

I suppose both are fine as long as needed libs can be found and configure outputs something like:

JPEG support............plugin



Next, I'll add "Q_IMPORT_PLUGIN(qjpeg)" (without ";" ?) at the top of my class .cpp and "QTPLUGIN += qgif qpng qjpeg" in my .pro file.

That's right ?
Yes, that's right. :)

Nyphel
7th October 2007, 15:35
(Small up, because JPN was writting an answer while I was posting more informations about my problem ^^)

Nyphel
7th October 2007, 18:04
Everything looks OK. Strange. See
>objdump.exe -t libqgif4.a
what function are in.
If there is no [_]qt_plugin_instance_qgif() then delete everything in plugins\imageformats folder and mingw32-make Qt library (or just mingw32-make in [qt base]\src\plugins\imageformats)




D:\Applications\Qt\4.3.1>cd plugins

D:\Applications\Qt\4.3.1\plugins>cd imageformats

D:\Applications\Qt\4.3.1\plugins\imageformats>objdump -t libqgif4.a
In archive libqgif4.a:

d000003.o: file format pe-i386

SYMBOL TABLE:
[ 0](sec 1)(fl 0x00)(ty 0)(scl 3) (nx 0) 0x00000000 .idata$4
[ 1](sec 2)(fl 0x00)(ty 0)(scl 3) (nx 0) 0x00000000 .idata$5
[ 2](sec 3)(fl 0x00)(ty 0)(scl 3) (nx 0) 0x00000000 .idata$7
[ 3](sec 3)(fl 0x00)(ty 0)(scl 2) (nx 0) 0x00000000 _qgif4_dll_iname



d000000.o: file format pe-i386

SYMBOL TABLE:
[ 0](sec 1)(fl 0x00)(ty 0)(scl 3) (nx 0) 0x00000000 .idata$2
[ 1](sec 2)(fl 0x00)(ty 0)(scl 3) (nx 0) 0x00000000 .idata$5
[ 2](sec 3)(fl 0x00)(ty 0)(scl 3) (nx 0) 0x00000000 .idata$4
[ 3](sec 1)(fl 0x00)(ty 0)(scl 2) (nx 0) 0x00000000 __head_qgif4_dll
[ 4](sec 0)(fl 0x00)(ty 0)(scl 2) (nx 0) 0x00000000 _qgif4_dll_iname



d000002.o: file format pe-i386

SYMBOL TABLE:
[ 0](sec 1)(fl 0x00)(ty 0)(scl 3) (nx 0) 0x00000000 .text
[ 1](sec 2)(fl 0x00)(ty 0)(scl 3) (nx 0) 0x00000000 .idata$7
[ 2](sec 3)(fl 0x00)(ty 0)(scl 3) (nx 0) 0x00000000 .idata$5
[ 3](sec 4)(fl 0x00)(ty 0)(scl 3) (nx 0) 0x00000000 .idata$4
[ 4](sec 5)(fl 0x00)(ty 0)(scl 3) (nx 0) 0x00000000 .idata$6
[ 5](sec 1)(fl 0x00)(ty 0)(scl 2) (nx 0) 0x00000000 _qt_plugin_query_verif
ication_data
[ 6](sec 3)(fl 0x00)(ty 0)(scl 2) (nx 0) 0x00000000 __imp__qt_plugin_query
_verification_data
[ 7](sec 0)(fl 0x00)(ty 0)(scl 2) (nx 0) 0x00000000 __head_qgif4_dll



d000001.o: file format pe-i386

SYMBOL TABLE:
[ 0](sec 1)(fl 0x00)(ty 0)(scl 3) (nx 0) 0x00000000 .text
[ 1](sec 2)(fl 0x00)(ty 0)(scl 3) (nx 0) 0x00000000 .idata$7
[ 2](sec 3)(fl 0x00)(ty 0)(scl 3) (nx 0) 0x00000000 .idata$5
[ 3](sec 4)(fl 0x00)(ty 0)(scl 3) (nx 0) 0x00000000 .idata$4
[ 4](sec 5)(fl 0x00)(ty 0)(scl 3) (nx 0) 0x00000000 .idata$6
[ 5](sec 1)(fl 0x00)(ty 0)(scl 2) (nx 0) 0x00000000 _qt_plugin_instance
[ 6](sec 3)(fl 0x00)(ty 0)(scl 2) (nx 0) 0x00000000 __imp__qt_plugin_insta
nce
[ 7](sec 0)(fl 0x00)(ty 0)(scl 2) (nx 0) 0x00000000 __head_qgif4_dll



D:\Applications\Qt\4.3.1\plugins\imageformats>


Oki, I deleted the contents of Qt4.3.1/plugins/imageformats (lots of .a and .dll files).

Next I made what he told me to do :
cd src
cd plugins
cd imagefomats
make

And now all works well.
My Qt4.3.1/plugins/imageformats dir contains 5 files :
- libqgif.a
- libqjpeg.a
- libqmng.a
- libqsvg.a
- libqtiff.a

When I build my application, I've no errors and I works perfectly :)
Thanks a lot !