views:

662

answers:

1

I have a Qt application that has some embedded JPG files that I want to display. When I compile and run both the debug and release versions on my machine, everything works perfectly. When I copy the application to a thumb drive and run it from there on my machine, it works fine. On the thumb drive and another developer's machine: OK. On the thumb drive on a third, non-developer's machine: no images!

proj.pri
RESOURCES += ./proj.qrc

proj.qrc:
<RCC>
<qresource prefix="/myApp">
    <file>Gui/Resources/logo.jpg</file>
    <file>Gui/Resources/another_image.jpg</file>
</qresource>
</RCC>

main.cpp:
{
    ...
    QImage *logo  = new QImage( ":/myApp/Gui/Resources/logo.jpg" );
    QImage *image = new QImage( ":/myApp/Gui/Resources/another_image.jpg" );

    myClass *d1 = new myClass( "Some Text", 48, 30, logo );
    myClass *d2 = new myClass( "Some More Text", 48, 30, another_image );
    ...
}

I have confirmed that the images are being added to the executable by commenting out the RESOURCES line in the .pri file. The size of the binary drops by the size of the images plus a bit; when I run the application, the images do not appear. I un-comment the RESOURCES line and everything works as described above.

What am I missing here? A DLL on the non-developer's machine? A

Environment:

  • Win XP
  • Qt 4.6.1
  • Visual Studio 2008
  • Qt Creator 1.3.1
+6  A: 

It needs jpeg plugin to load images. If you have Qt installed they would be in %QTDIR%\plugins\imageformats.

Copy qjpeg4.dll into plugin folder on your thumb drive.

root/app.exe
root/qt.conf
root/plugins/imageformats/qjpeg4.dll

In qt.conf file set path to your plugins dir:

[Paths]
plugins=./plugins
Eugene
I have experienced this before and this is the solution I stumbled on. OP, keep in mind that the directory structure may matter.
San Jacinto
BTW, copied imageformats/qjpeg4.dll into root (as in the example above) and left out qt.conf and root/plugins.
dwj
Yeah this might be a bit redundant, but I don't remember exact order of lookup Qt does :).
Eugene
@Eugene...thanks...this really helped me.
csmithmaui