Results 1 to 5 of 5

Thread: What's the problem with setPixmap?

  1. #1
    Join Date
    Dec 2007
    Location
    London
    Posts
    206
    Thanks
    40
    Qt products
    Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android

    Default What's the problem with setPixmap?

    I 'm using qt4.4.0. I created a form on Qt creator. I just added a simple label on the form; and I set a pixmap on the label by using property editor( a png image). Whan i run the application, the set pixmap is not shown ?

    I also set the pixmap manually on the contructor; the result didn't change.

    I did that hundres of times in qt4.2.; but i didnt face anything like that. May it be that : png' s format options are also important for qt?

  2. #2
    Join Date
    Dec 2007
    Location
    London
    Posts
    206
    Thanks
    40
    Qt products
    Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android

    Default Re: What's the problem with setPixmap?

    I think the problem is with the qrc file or the resource compiler.

    I changed :

    label->setPixmap(QPixmap(QString::fromUtf8(":/imagework/DSC00502.PNG")));

    in the generated ui file to:

    ui.label->setPixmap(QPixmap(QString::fromUtf8("D:\DSC00502. PNG")));

    and used it in the constructor; and this worked. Why doesnt it work with the qrc file way ?

  3. #3
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,368
    Thanks
    3
    Thanked 5,017 Times in 4,793 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: What's the problem with setPixmap?

    Did you link with that resource file?

  4. #4
    Join Date
    Dec 2007
    Location
    London
    Posts
    206
    Thanks
    40
    Qt products
    Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android

    Default Re: What's the problem with setPixmap?

    Ok, ok, again you are right :-)
    But, i thought that it would automatically add the resource file to the project. One more thing: I added the qrc file into RESOURCES in .pro file for linux. it is ok.. But for windows, I use visual studio integration; and qrc file is inside of the solution(Resource files); however it again cannot recognize the resources...Where should i add it to be able to link?

  5. #5
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,368
    Thanks
    3
    Thanked 5,017 Times in 4,793 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: What's the problem with setPixmap?

    Use a project file for qmake (you can later again generate a VS project from it) or the project editor inside VS integration.

Similar Threads

  1. Very strange socket programming problem
    By montylee in forum Qt Programming
    Replies: 5
    Last Post: 11th November 2008, 12:05
  2. Weird problem: multithread QT app kills my linux
    By Ishark in forum Qt Programming
    Replies: 2
    Last Post: 8th August 2008, 09:12
  3. Steps in solving a programming problem?
    By triperzonak in forum General Programming
    Replies: 8
    Last Post: 5th August 2008, 08:47
  4. problem with paint and erase in frame
    By M.A.M in forum Qt Programming
    Replies: 9
    Last Post: 4th May 2008, 20:17
  5. Replies: 16
    Last Post: 7th March 2006, 15: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
  •  
Qt is a trademark of The Qt Company.