Silnik
Silnik

Reputation: 328

Qt: setting text to a Qlabel with a pixmap and back

So i have a QLabel with a pixmap (added to it with the function setPixmap() ). Let's say now I add text to it with setText(). The QLabel starts displaying the text which is what I want it to do. And now is my question - is there a way to change the label back to start showing the previous pixmap rather than adding it again with setPixmap()?

Upvotes: 0

Views: 1682

Answers (2)

David Casper
David Casper

Reputation: 430

This limitation from Qt 4.8 which still appears to be there can be overcome by using:

setStyleSheet("background-image: url(:/images/sunset.jpg);");

For more information see: Unable to set the background image in Qt Stylesheet

Upvotes: 0

Ashot
Ashot

Reputation: 10979

No.

http://qt-project.org/doc/qt-4.8/qlabel.html#text-prop

Here is written that setting text to QLabel clears any previous content.

Upvotes: 1

Related Questions