Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. QLabel pixmap not clearing

QLabel pixmap not clearing

Scheduled Pinned Locked Moved General and Desktop
qt 4.8qpixmapqlabeltransparency
1 Posts 1 Posters 3.1k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • T Offline
    T Offline
    Tymer
    wrote on last edited by
    #1

    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();
    }
    
    1 Reply Last reply
    0

    • Login

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Get Qt Extensions
    • Unsolved