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 does not correctly display .PNG transparency
Qt 6.11 is out! See what's new in the release blog

QLabel does not correctly display .PNG transparency

Scheduled Pinned Locked Moved General and Desktop
qlabel png tran
2 Posts 2 Posters 1.4k Views 2 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.
  • C Offline
    C Offline
    ChasersDoom
    wrote on last edited by ChasersDoom
    #1

    I just upgraded from Qt 5.1.1 fto Qt 5.5.x. When using 5.1.1, I can overlay labels containing .png images over other labels or frames containing .png images and the transparency of the images is correctly displayed. When I compile the same code using 5.5.x, the images now have a solid colored square around them, where that area should be transparent. Is there a QLabel setting that has changed its default value since 5.1.1? I am using Qt Creator to configure the window and .setStyleSheet to display them.

    MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow)
    {
    ui->setupUi(this);

    QString frameStyle = "QFrame {border-image: url(CLIENTRUN/IMAGE_FILES/background_layer_bottom.png)};";
    ui->frame->setStyleSheet(frameStyle);
    
    QString label1Style = "QLabel { border-image: url(CLIENTRUN/IMAGE_FILES/tuxvader.png) };";
    ui->textlabel1->setStyleSheet(label1Style);
    
    QString label2Style = "border-image: url(CLIENTRUN/IMAGE_FILES/tuxreaper.png);";
    ui->textlabel2->setStyleSheet(label2Style);
    

    }

    1 Reply Last reply
    0
    • mrjjM Offline
      mrjjM Offline
      mrjj
      Lifetime Qt Champion
      wrote on last edited by
      #2

      hi
      Qt5.5 , 2 labels assigning png directly to Pixmap seems to work fine.
      http://postimg.org/image/mmukajusf/

      For test did you try a new project and load the png directly and see if the result is the same?

      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