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

QWebEngineView does not handle native transparent background correctly

    XMLWordPrintable

Details

    Description

      Reproducer attached. It features a transparent root QWidget with 2 sub widgets. From top to bottom:
      1. A 600x300 webWidget that contains a 400x300 QWebEngineView.
      2. A 600x300 labelWidget that contains a 400x300 QLabel.

      The design is that there is 200x300 transparent area to the right of both QWebEngineView and QLabel. To reproduce the problem, build the reproducer against 6.8.2 and one will see:

      The labelWidget on the bottom is all good that the transparent part stays transparent. But for webWidget, somehow the transparent part is rendered in black.

      The problem is native widget:

      labelWidget->setAttribute(Qt::WA_NativeWindow);
      

      Although it is set to labelWidget, everything becomes native at the end. And somehow, webWidget cannot handle native transparent background correctly. And since labelWidget is not affected, I think it is due to QWebEngineView.

      BTW, the problem can be also triggered by calling winId(), which is essentially making everything native too. And somehow "Qt::WA_DontCreateNativeAncestors" doesn't work. One can do

      labelWidget->setAttribute(Qt::WA_DontCreateNativeAncestors);
      

      before calling winId() or setAttribute(Qt::WA_NativeWindow). It doesn't change anything. And "root->testAttribute(Qt::WA_NativeWindow);" still reports "true".

      Attachments

        1. image-2025-03-21-15-11-41-799.png
          47 kB
          Luqiao Chen
        2. QTBUG-135012.7z
          1 kB
          Luqiao Chen
        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            qt_webengine_team Qt WebEngine Team
            luqiaochen Luqiao Chen
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:

              Gerrit Reviews

                There are no open Gerrit changes