Results 1 to 10 of 10

Thread: setPixmap

  1. #1
    Join Date
    Apr 2006
    Posts
    16
    Thanks
    3
    Qt products
    Qt4
    Platforms
    Windows

    Default setPixmap

    Hi All,
    I'm having some trouble using the QLabel->SetPixmap
    method in Windows. My application has a label and I am trying to add a pixmap on it. The pixmap is located under Resource Files picture.qrc.
    The following code is the simplest example of what I'm doing:

    void AModule:penRDialog()
    {
    QPixmap pmap(720,840);
    QString iconstr = "icture//A.png";
    pmap.load(iconstr,"PNG",Qt::ColorOnly);
    mDialog->ui.i90label->setPixmap(pmap);
    mDialog->exec();
    }

    When I run the application all I could see is empty gray picture on the label.
    If I put png file outside the Resources file and delete the picture.qrc
    and give the new path name as

    QString iconstr = "C://libraries//MODULE//A.png";

    I could see the pixmap on the label. But this time,
    I can't carry this exe to another machine without the png file.
    How could I solve this problem? Any help will be appriciated.

  2. #2
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: setPixmap

    Could we see the contents of .qrc file?
    J-P Nurmi

  3. #3
    Join Date
    Apr 2006
    Posts
    16
    Thanks
    3
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: setPixmap

    Quote Originally Posted by jpn View Post
    Could we see the contents of .qrc file?
    here is the picture.qrc :

    <RCC>
    <qresource prefix = "/picture">
    <file>A.png</file>
    </qresource>
    </RCC>

    Thank you in advance.

  4. #4
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: setPixmap

    Try with ":/picture/A.png".
    J-P Nurmi

  5. #5
    Join Date
    Apr 2006
    Posts
    16
    Thanks
    3
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: setPixmap

    Quote Originally Posted by jpn View Post
    Try with ":/picture/A.png".
    sorry but didn't work...

    thanks

  6. #6
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: setPixmap

    Just to assure, the resource file is listed in RESOURCES variable in the .pro file?
    J-P Nurmi

  7. #7
    Join Date
    Apr 2006
    Posts
    16
    Thanks
    3
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: setPixmap

    Quote Originally Posted by jpn View Post
    Just to assure, the resource file is listed in RESOURCES variable in the .pro file?
    yes, it is listed.

  8. #8
    Join Date
    Jan 2006
    Location
    Paris, France
    Posts
    227
    Thanks
    3
    Thanked 21 Times in 21 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: setPixmap

    Could you provide a small sample we can test ?

  9. #9
    Join Date
    Nov 2006
    Location
    Shrewsbury, UK
    Posts
    97
    Thanks
    3
    Thanked 11 Times in 11 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: setPixmap

    Quote Originally Posted by jpn View Post
    Try with ":/picture/A.png".
    That should be colon ':' not a semi-colon ';'.

    Pete

    p.s. QString iconstr = "C://libraries//MODULE//A.png";

    should be QString iconstr = "C:\\libraries\\MODULE\\A.png"; for Windows (probably QString iconstr = "C:/libraries/MODULE/A.png"; will work with Qt). Remember that '\' is the escape character not '/'.

  10. #10
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: setPixmap

    Quote Originally Posted by pdolbey View Post
    That should be colon ':' not a semi-colon ';'.
    Hmm, italic font just makes it look like a semi-colon.
    J-P Nurmi

Similar Threads

  1. QDrag setPixmap failed with "XBM" format
    By alfa_wu in forum Qt Programming
    Replies: 2
    Last Post: 2nd May 2007, 02:32
  2. QLabel not resize in setPixmap()
    By xgoan in forum Newbie
    Replies: 3
    Last Post: 23rd October 2006, 12:21
  3. QTreeWidget - setPixmap???
    By durbrak in forum Qt Programming
    Replies: 12
    Last Post: 10th October 2006, 06:57

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.