Important: Please read the Qt Code of Conduct -

Issue with WA_TranslucentBackground again

  • Hi there,
    For many days now I have tried to have a window with a transparent background by using "WA_TranslucentBackground". But it did not work neither on Qt 4.8 or Qt 5.1.1 . When I use it the background stays black. Here is the code:

    @#include <QtGui>
    #include "mainwindow.h"
    #include "ui_mainwindow.h"

    MainWindow::MainWindow(QWidget *parent) :
    ui(new Ui::MainWindow)
    setAttribute(Qt::WA_TranslucentBackground, true);

    delete ui;

    the code
    @setStyleSheet("background: transparent;");
    doesn't work too and gives the same result.

    Please someone knows what is wrong or at least has an application working with "WA_TranslucentBackground" or "setStyleSheet("background: transparent;")" ?

    NB: I am working on Windows Xp but both codes work well on Linux. In addition this problem seems recurrent and many bug reports and threads exist concerning "WA_TranslucentBackground" but without any solution. I am wondering if the Digia's staff is working on it.

  • Help please!

  • you are wrong, read the manual you will know, there need setWindowFlags(Qt::FramelessWindowHint) to be set.

  • Sorry Peterchou but as the function says itself, it allows just to remove the window's frame. So I can add it or not it wont change the problem... The question is: how do you get a window's background transparent with frame?

Log in to reply