PDA

View Full Version : What's the problem with setPixmap?



yagabey
21st November 2008, 08:10
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?

yagabey
21st November 2008, 09:08
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 ?

wysota
21st November 2008, 10:11
Did you link with that resource file?

yagabey
21st November 2008, 14:13
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?

wysota
21st November 2008, 16:34
Use a project file for qmake (you can later again generate a VS project from it) or the project editor inside VS integration.