Results 1 to 3 of 3

Thread: Unable to resolve the relative in QLabel::setPixmap()

  1. #1
    Join Date
    Apr 2007
    Location
    Bangalore,India
    Posts
    25
    Thanks
    2
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Unable to resolve the relative in QLabel::setPixmap()

    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.

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

    Qt Code:
    1. // Not setting pixmap
    2. labelObj_1->setPixmap( QPixmap("../icons/RIcon.xpm" ) );
    3. // Setting pixmap
    4. labelObj_2->setPixmap( QPixmap( "/root/Desktop/source/icons/TIcon.xpm" ) );
    To copy to clipboard, switch view to plain text mode 

    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..
    Veda

  2. #2
    Join Date
    Jan 2006
    Location
    Bremen, Germany
    Posts
    554
    Thanked 86 Times in 81 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Unable to resolve the relative in QLabel::setPixmap()

    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?

  3. #3
    Join Date
    Jan 2006
    Location
    Ohio
    Posts
    332
    Thanks
    37
    Thanked 8 Times in 4 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Unable to resolve the relative in QLabel::setPixmap()

    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?

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.