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. SetWindowOpacity doesn't work
Qt 6.11 is out! See what's new in the release blog

SetWindowOpacity doesn't work

Scheduled Pinned Locked Moved General and Desktop
2 Posts 1 Posters 5.4k 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.
  • K Offline
    K Offline
    kajojeq
    wrote on last edited by
    #1

    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

    per aspera ad astra

    1 Reply Last reply
    0
    • K Offline
      K Offline
      kajojeq
      wrote on last edited by
      #2

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

      per aspera ad astra

      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