Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-95042

QFrame Qt::WA_TranslucentBackground is broken with specific window flags and drawable child item

    XMLWordPrintable

Details

    • macOS
    • e71a5d5cc3c0337e7dbd5d571ecee5668baf8b63 (qt/qtbase/dev) cdec9d739d35e336e2bd18a2d2c5863c1002c569 (qt/qtbase/6.2) 78ca39fbb06dc87dbfd87952e4cc67e3c5141297 (qt/tqtc-qtbase/5.15) e8d39c670ee9ee5f097fcab27c8070103a3c4b68 (qt/qtbase/6.1)

    Description

      There is a bug when using Qt::Tool | Qt::FramelessWindowHint and Qt::WA_TranslucentBackground on a QFrame and drawing something on top of that QFrame with Qt 6.2.0 on macOS.
      With Qt 5.15.5 the background is translucent as set via the setAttribute() function, but in Qt 6.2.0 this background is gray as shown in the screenshots.

      Qt 5.15.5 Qt 6.2.0

      This works without problems under Windows and Linux with Qt 5.15.5 as well as with 6.2.0.

      #include <QtWidgets>
      #include <QHBoxLayout>
      
      int main(int argc, char *argv[])
      {
          QApplication app(argc, argv);
          QWidget *window = new QWidget();
          window->resize(320, 240);
          window->show();
          window->setWindowTitle("Hello World");
      
          QLabel *label = new QLabel();
          label->setText("This should be visible!");
          label->setAlignment(Qt::AlignHCenter | Qt::AlignVCenter);
      
          QHBoxLayout *windowLayout = new QHBoxLayout(window);
          windowLayout->addWidget(label);
      
          QFrame *frame = new QFrame(window);
          frame->setWindowOpacity(1);
          frame->setWindowFlags(Qt::Tool | Qt::FramelessWindowHint);
          frame->setAttribute(Qt::WA_NoSystemBackground);
          frame->setAttribute(Qt::WA_TranslucentBackground);
          frame->setGeometry(window->frameGeometry());
          frame->setVisible(true);
      
          QLabel *topLabel = new QLabel(frame);
          topLabel->setText("Top Label");
      
          QHBoxLayout *frameLayout = new QHBoxLayout(frame);
          frameLayout->addWidget(topLabel);
      
          return app.exec();
      }
      

      This mechanism is used in QtDesignStudio to implement the docking overlay within the "AdvancedDockingSystem" - with that bug it is unusable.

      Attachments

        1. macOS-5_15_5.png
          macOS-5_15_5.png
          39 kB
        2. macOS-6_2_0.png
          macOS-6_2_0.png
          15 kB

        Issue Links

          For Gerrit Dashboard: QTBUG-95042
          # Subject Branch Project Status CR V

          Activity

            People

              vestbo Tor Arne Vestbø
              henning Henning Gründl
              Votes:
              0 Vote for this issue
              Watchers:
              9 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: