[solved] Displaying a .jpg picture in a QPixmap

Hi @ all!

I want to display some jpg - pictures in a QPixmap.
On my Host machine it is working, but if I compile the program for QNX then the images are not loaded.
pixmap.load() returns “false”.

There are no error messages or warnings when starting the program, so I don´t know what the problem could be…
As plugin there is “libqjpeg.so” under “usr/lib/qt4/plugins/imageformats”
And with QML, jpg´s are working.

Does anyone have an idea what I am doing wrong?

EDIT:

By using the shell the QML demo programs are running properly, but by using momentics to start the programs (and stopped shell) then I get also an error:

Your post creates a number of questions.

What does “on my host it is working”? Is your host a Windows system or something else?
What do you mean by “using Momentics to start the program”? Are you starting the program on a QNX target system from Momentics on a host system?

Why does the error message have “file:///tabs/content/images/tab_r.jpg” as the format. “file:///…” is not part of the QNX file system. This prefix is a URL indicating that the resource should come from the local file system, but “file://” should not be there when passed to the QNX open() call. I don’t know if this is just a confusion created by Qt or if something is actually wrong.

The error message suggests that JPEG support might not be compiled into Qt. This seems unlikely. I suspect that Qt uses libjpeg for this support, and so it might indicate that Qt is not finding or the libjpeg.so is missing from your target.

here the answers to your questions:

  • my host is indeed a Windows 8 machine
  • I use QNX Momentics for compiling and sending the resulting binary to a beagleboard via ethernet. → So, Yes I start the program from the host machine
  • I don´t know why this error message is appearing, but this program was a demo from the QNX for Beagleboard demo available at foundry27

Further information:
I stop the shell at the begining, because it disrupts my communication via RS232.
The demo is running properly when started from shell. My program can also load the jpg´s but is not displaying anything.
Without the shell the mentioned error appears. So some environment variables are missing.
I tried to export in the .profile-file all variables I can see if I type “set” into the shell.
But it is still not working…
( “#” marks the point after which I added the variables)

EDIT:
I played a little bit around with the setting and now the jpg´s are working if started with momentics.
The missing part was LD_LIBRARY_PATH and PATH in the “run configurator” as additional environment variable.
BUT if I start the binary from the board then the jpg´s cannot be loaded anymore.
This is confusing me a bit, because I could get the needed setings from the shell with “set”.
Are these settings deleted if I kill the shell?

Ok, I think it is pretty clear right now. Your problem has to do with environment variables and specifically LD_LIBRARY_PATH.
The shell is merely a conduit for environment variables. When you start a program from the shell, it passes them on to the program being executed. If you start a program from somewhere other than the shell, you have to either create or pass them on yourself.

I think that what has happened is that the Qt routines are looking for libjpeg.so. If they are using the LD_LIBRARY_PATH to find then, and it’s not set up right, they won’t find it.

Do you know a good way to give a program started on the Board these environment variables?
In my case I either make a bin which consists off

cd /folder
./program_name -qws &

and start it via QNX momentics or I use a rc.local - file from the demo in which I can write some additional commands. These commands are executed after the startup script. There I start the aforementioned bin.

I already tried to execute the export commands, but this isn´t working. (In fact, it looks like a freeze of the OS )

You can set environment variables in the boot script, or if you use one in the rc.local script.
There’s also shell syntax that sets a variable for a specific program, eg.:

LD_LIBRARY_PATH=/proc/boot:/lib:/usr/lib:/lib/dl ./program_name -qws &

Ok Thanks alot maschoen :slight_smile:

I don´t know what was going wrong before when I tried to export the variables in the rc.local script, but now it is working!