I have a transparent QGraphicsWebview
inside a QGraphicsView
with the following settings:
QGraphicsView
is the high level widget, and is shown in full screen modeQGLWidget
as its view port (to use opengl-es)
graphicsView->setStyleSheet("background:transparent")
QPalette::Base
and QPalette::Window
brushes of webview and webview->page()
are set to Qt::transparent
At the beginning, the transparency works fine. But as the screen get updated (when I scroll), it looks like the new bitmap is blended on top of the existing one to get a superimposed picture. After about 5-6 screen updates, this blending causes the colors to accumulate and form an opaque rectangle (with a corrupted image). Following images show first, second and final stages of the problem.
How do I tell qt/opengl to stop blending and just draw the new image to the frame buffer?
I tried calling fillRect(boundRect(), Qt::transparent)
from overridden Webview::paint and GraphicsView::paintEvent; but it didn't work except for making the updates slower.
I am new to Qt and OpenGl, so I might be missing some basic flags or settings.
It turns out the problem is graphicsView->setStyleSheet("background:transparent");
. Who would have guessed?!
Yeah, the line that I thought made transparency work was actually causing troubles with transparency. The application works fine without that line (or if you change it to background:none
)
In short, steps to get a transparent QGraphicsWebview using QGLWidget:
QGraphicsWebview
, QWebpage
and the outer QGraphicsView
to Qt::transparent
scene->setBackgroundBrush(QBrush(Qt::transparent));
You should also make sure that html body background is set to transparent values:
html, body {
background-color: rgba(127, 127, 0, 0.5);
}