PDA

View Full Version : Unable to resolve the relative in QLabel::setPixmap()



veda
14th June 2007, 13:47
Hello,


We are trying to set a pixmap in QLabel.. but when i give the relative path the QLabel is not displaying the QPixmap...
the hierarchy is as below.


/root/Desktop/source
| |
| |
dlg icons
I have My sourcefile *.cpp in dlg and pixmap (*.xpm) in icons..



// Not setting pixmap
labelObj_1->setPixmap( QPixmap("../icons/RIcon.xpm" ) );
// Setting pixmap
labelObj_2->setPixmap( QPixmap( "/root/Desktop/source/icons/TIcon.xpm" ) );


labelObj_1 is unable to resolve the path and not setting the pixmap.. where as
labelObj_2 is able to set the pixmap....

Why the label not resolving if the relative path given....,?????
thanks..

ChristianEhrlicher
14th June 2007, 14:14
Becasue the relative path is maybe not correct... how do you know where the current application dir is?
Why not using resources instead loading them from somewhere in your filesystem where you can't know if the file is really there?

ToddAtWSU
14th June 2007, 14:31
Is your program located inside "/root/Desktop/source/programdir"? If it is located there then I would think the path "../icons/RIcon.xpm" would work. Also, you say "..icons/RIcon.xpm" doesn't work but "/root/Desktop/source/icons/TIcon.xpm" works. Well, you are trying to use 2 different XPMs here, RIcon and TIcon. Could it be RIcon.xpm doesn't exist and TIcon.xpm does exist?