QLabel pixmap not clearing
-
Hello, I'm having QPixmap issues yet again....
The documentation has led me to believe that the pixmap of a QLabel is cleared after QLabel::setPixmap. However, this does not seem to be the case. I have two images, but for this example I'm just going to do an image filled with red for one. The other will be called redandblue.png. I want to switch between red and redandblue.png, but redandblue.png has a transparent background. When I try and bring it up after the red, I just see some blue lines on a red background. This makes some sense, since redandblue.png has a transparent background. However, shouldn't the red be gone if I'm doing (psuedocode) label->setPixmap(redandblue.png)?Here's some code: (note: there are some redundant lines that I'm leaving to show that they aren't helpful, and some lines omitted for brevity)
void myWidget::myWidget() { // QPixmap redandblue in header redandblue = QPixmap(":/path/to/redandblue.png"); }
Thanks in advance.
void myWidget::setRed()
{QImage img(120, 120, QImage::Format_ARGB32); img.fill(Qt::red); ui->myLabel->setPixmap(QPixmap::fromImage(img)); this->repaint(); this->update(); } void myWidget::setRedAndBlue() { ui->myLabel->setPixmap(redandblue); this->repaint(); ui->myLabel->update(); }