You are not logged in.

Dear visitor, welcome to QtForum.org. If this is your first visit here, please read the Help. It explains in detail how this page works. To use all features of this page, you should consider registering. Please use the registration form, to register here or read more information about the registration process. If you are already registered, please login here.

1

Tuesday, January 11th 2005, 6:25am

QPixmap in QListBox

I am doing the following:


image_add.load("1.jpg");
listBox1->insertItem(image_add,0);
listBox1->insertItem("",1);
image_add.load("2.jpg");

Using the above method I am loading 6 pixmaps in the listBox.
I am using QT on Linux. I compile my program using

qmake -makefile project.pro
make
and then execute it using
./project

In the above case everything works fine. I can see the pixmaps in the listbox.


However instead of "./project", if I directly double click on the executable file created, the pixmaps cannot be seen in the listbox at all.
All functionalities work fine execpt for those concerning pixmaps.. for eg "setPixmap" on textLabel does not work.
Am I loading the pixmaps correctly?
Thank you for your help..

  • "Petr Svetr Killometr" is male

Posts: 55

Location: Czech Republic

  • Send private message

2

Tuesday, January 11th 2005, 6:48am

RE: QPixmap in QListBox

Try to use absolute file path, when you loading the images.

mick

Trainee

Posts: 55

Location: Vancouver, BC, Canada

Occupation: Biologist

  • Send private message

3

Wednesday, January 12th 2005, 3:01am

RE: QPixmap in QListBox

If you load bitmap resources into your program using their filenames, they will need to be in the correct location (i.e. the correct folder relative to the application), as mandira said.

If you use absolute paths it will work, but it's a bit unreliable if you wish to distribute the app to other users, because they can and will move or rename folders, and at some point your images will vanish.

I prefer to use uic or qembed to load the required bitmaps into a c++ file that is compiled directly into the executable.

This link might be useful: http://doc.trolltech.com/qq/qq05-iconography.html but it doesn't mention uic (which I have found to be the best method)

Good luck

mick