PDA

View Full Version : setText and setPixmap functions



rapid84
10th February 2016, 15:55
Hi,
I am using setText function and setPixmap functions to show png icons and some values like this :


ui->label->setText(value);



QPixmap pix1(":/resources/images/images/01n.png");
ui->label_2->setPixmap(pix1);


I want to combine both of them in one setText function like this:



ui->label_3->setText(pix1 + value);


How can i do this?

d_stranz
10th February 2016, 16:49
How can i do this?

Obviously, you can't. A QString is not a QPixmap and a QPixmap is not a QString. What could possibly be the meaning in C++ of adding together a text string and an image as an argument to a function call which expects a QString? You call QLabel::setText() with the string and QLabel::setPixmap() with the image.