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

MainWindow is painted black when QWebEngineView is embedded in it, although it should maintain transparency.

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Reported
    • Priority: P3: Somewhat important
    • Resolution: Unresolved
    • Affects Version/s: 5.15.2, 6.2.0 Beta1
    • Fix Version/s: None
    • Labels:
      None
    • Environment:
      Windows 10 Pro x64
    • Platform/s:
      Windows

      Description

      Hello, I found a very strange bug. When using QWebEngineView, the transparent background of the MainWindow is filled with black.

      Checking how transparency works with WebEngineView:

      (5.15.2)

      (6.0.2.beta-1)

      screen: (black background MainWindow)

      console(Crash QWebEngine, but the background has become black anyway):

      Source code:

      main.cpp

      #include "mainwindow.h"
      #include <QApplication>
      int main(int argc, char *argv[])
      {
       QApplication a(argc, argv);
       MainWindow w;
       w.setWindowFlags(Qt::FramelessWindowHint);
       w.show();
       return a.exec();
      }
      

       

       

      mainwindow.cpp

      #include "mainwindow.h"
      #include "ui_mainwindow.h"
      MainWindow::MainWindow(QWidget *parent)
       : QMainWindow(parent)
       , ui(new Ui::MainWindow)
      {
       ui->setupUi(this);
      setAttribute(Qt::WA_TranslucentBackground);
       setAutoFillBackground(true);
       ui->centralwidget->setAttribute(Qt::WA_TranslucentBackground);
       ui->webEngineView->setAttribute(Qt::WA_TranslucentBackground);
       ui->webEngineView->setStyleSheet("background:transparent");
       ui->webEngineView->page()->setBackgroundColor(Qt::transparent);
       ui->webEngineView->setUrl(QUrl("https://google.com"));
      }
      MainWindow::~MainWindow()
      {
       delete ui;
      }
      

      mainwindow.h

      #ifndef MAINWINDOW_H
      #define MAINWINDOW_H
      #include <QMainWindow>
      QT_BEGIN_NAMESPACE
       namespace Ui
      { class MainWindow; }
      QT_END_NAMESPACE
      class MainWindow : public QMainWindow
       {
       Q_OBJECT
      public:
       MainWindow(QWidget *parent = nullptr);
       ~MainWindow();
      private:
       Ui::MainWindow *ui;
      };
       #endif // MAINWINDOW_H
      

       

      mainwindow.ui
      (where the white rectangle is a QWighet converted to a QWebEngineView, and everything else has transparency)

      When I deleted this wighet and deleted 4 lines of code( where WebEngineView is present), everything worked for me and it is transparent. Is it possible that this is a bug with QWebEngineView, which for some reason affects the style of the entire MainWindow?

       

      (A screenshot of the fact that transparency works if there is no QWebEngineView, It works perfectly on 5.15.2 and 6.0.2.beta)

        Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

          Activity

            People

            Assignee:
            qt_webengine_team Qt WebEngine Team
            Reporter:
            sepera_okeq Sergey Okeq
            Votes:
            1 Vote for this issue
            Watchers:
            1 Start watching this issue

              Dates

              Created:
              Updated:

                Gerrit Reviews

                There are no open Gerrit changes