Important: Please read the Qt Code of Conduct -

QLabel does not correctly display .PNG transparency

  • 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) :
    ui(new Ui::MainWindow)

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


  • Lifetime Qt Champion

    Qt5.5 , 2 labels assigning png directly to Pixmap seems to work fine.

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

Log in to reply