Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

SetWindowOpacity doesn't work



  • I am using qt 5.1.0 on windows 7 I opened simple GUI application added one button to main window. After you click on it QDialog is opened (or Qlabel, QSplashScreen etc. by ->show() ) . I want both of this windows to be transparent:

    @
    void MainWindow::on_pushButton_clicked()
    {
    QDialog *qd = new QDialog();
    qd->setFixedSize(this->width(),this->height());
    this->setWindowOpacity(0.5); //this work
    qd->setWindowOpacity(0.5); // this is not
    qd->show();
    }
    @

    Why it is not working on other objects than mainwindow? Even if I don't create MainWindow anything else can be transparent I tried other things too:

    @
    qd->setPalette(QPalette(QPalette::Window,QColor(0,0,0,128)));
    setAttribute(Qt::WA_TranslucentBackground);
    qd->setWindowFlags(Qt::FramelessWindowHint);
    setWindowFlags(Qt::FramelessWindowHint);
    qd->setStyleSheet("background:transparent;background-color:rgba(0,0,0‌​,95)");
    qd->repaint();
    QGraphicsOpacityEffect *opacityEffect = new QGraphicsOpacityEffect;
    opacityEffect->setOpacity(0.5);
    qd->setGraphicsEffect(opacityEffect);
    @

    I asked on other forum when somone told me that for his version 4.8.4 my code works fine.
    Thanks for any help!

    SOLVED!!!
    https://bugreports.qt-project.org/browse/QTBUG-33078



  • I checked in my PC in home (5.0.1 windows7) this code works fine. Can somone else on 5.1.0 try out?


Log in to reply