Details
-
Bug
-
Resolution: Unresolved
-
P3: Somewhat important
-
None
-
5.6.0
-
None
-
Windows 8.1 x64 + Visual Studio 2015
Description
Assume we have a widget, which must be transparent. Its transparency is achieved by means of QGraphicsOpacityEffect. When the widget is shown on top of the QWebEngineView and the parent window contains some another widget, for which winId() was called, transparency effect doesn't work.
The following code demonstrates the issue:
#include <QtCore> #include <QtWidgets> #include <QtWebEngineWidgets> #include <QGraphicsOpacityEffect> class TransparentWindow : public QWidget { public: TransparentWindow(QWidget *parent); protected: virtual void paintEvent(QPaintEvent *event); }; TransparentWindow::TransparentWindow(QWidget *parent) : QWidget(parent, Qt::Widget | Qt::FramelessWindowHint | Qt::WindowStaysOnTopHint | Qt::X11BypassWindowManagerHint) { resize(parent->width(), parent->height() / 2); QGraphicsOpacityEffect *effect = new QGraphicsOpacityEffect; effect->setOpacity(0.5); setGraphicsEffect(effect); } void TransparentWindow::paintEvent(QPaintEvent *event) { QPainter painter(this); painter.setPen(Qt::NoPen); painter.setBrush(QColor(200, 20, 20, 255)); painter.drawRoundedRect(painter.viewport(), 50, 50, Qt::AbsoluteSize); painter.setPen(QColor(Qt::white)); painter.drawText(rect(), Qt::AlignCenter | Qt::TextWordWrap, "Transparency bug around child winId() and QWebEngineView"); } int main(int argc, char * argv[]) { QApplication app(argc, argv); QMainWindow mw; mw.resize(1000, 1000); QSplitter * splitter = new QSplitter(Qt::Horizontal); QWidget *child = new QWidget; child->winId(); // ! Removing this line fixes the issue ! splitter->addWidget(child); splitter->addWidget(new QWebEngineView); // ! Replacing QWebEngineView with some another widget also fixes the issue ! //splitter->addWidget(new QWidget); mw.setCentralWidget(splitter); mw.show(); // show the transparent popup TransparentWindow *transparentWindow = new TransparentWindow(&mw); transparentWindow->show(); return app.exec(); }
The widget must be semi-transparent, but its right part (which is on top of the web view) is not transparent:
If we replace QWebEngineView with some another widget or don't call winId() for another widget, transparency will work fine.
The sample project is attached.
Attachments
Issue Links
- relates to
-
QTBUG-51793 [OS X]: When resizing or causing an update to a window containing a native widget it will flicker to black and black for every update
- Closed
-
QTBUG-53214 QWebEngineView / winId() conflict
- Closed