PDA

View Full Version : How do i change images? Qt creator label>pixmap



QueenZ
7th February 2010, 15:32
I got errors with my code...


ui->label->pixmap(":/new/prefix1/images/solve3.png");

also got errors with this code...


char[32] urr = ":/new/prefix1/images/solve3.png";
ui->label->pixmap(urr);


ERRORS:
/Users/martins/showhide/mainwindow.cpp:31: error: no matching function for call to 'QLabel::pixmap(const char [32])'

/Library/Frameworks/QtGui.framework/Headers/qlabel.h:75: note: candidates are: const QPixmap* QLabel::pixmap() const

aamer4yu
7th February 2010, 18:05
its QLabel::setPixmap()
Qlabel::Pixmap() returns you the current pixmap.

QueenZ
7th February 2010, 20:05
thanks, but this doesn't work either...


ui->label->setPixmap(":/new/prefix1/images/FirefoxCool.png");

C:/Users/QueenZ/Desktop/showhide/showhide/mainwindow.cpp:32: error: no matching function for call to 'QLabel::setPixmap(const char [37])'

c:\Qt\2010.01\qt\include/QtGui/../../src/gui/widgets/qlabel.h:116: note: candidates are: void QLabel::setPixmap(const QPixmap&)

p4plus2
7th February 2010, 22:53
The function you want would be void QLabel::setPixmap(const QPixmap&)
So I think you would need syntax that looks similar to this:


QPixmap *pixmap = new QPixmap(":/new/prefix1/images/FirefoxCool.png");
ui->label->setPixmap(pixmap);

I have not tested this nor have I ever used QPixmap so you may need to mess around with this a bit, but this should get you started.

aamer4yu
8th February 2010, 05:44
or simply ui->label->setPixmap(QPixmap(":/new/prefix1/images/FirefoxCool.png") );