Nested QGraphicsView + OpenGL issue

  • I am having an issue when I embed a QWidget into a QGraphicsScene and the widget I am embedding contains another instance of the same QGraphicsView that is hosting the scene. My QGrapicsScene is set to render using OpenGL by setting the viewport to a QGLWidget. First I do understand the docs for QGraphicsScene have this to say on the subject bq. Note that widgets with the Qt::WA_PaintOnScreen widget attribute set and widgets that wrap an external application or controller are not supported. Examples are QGLWidget and

    With that said, all my QGLWidgets are set to share the same GLContext which should make this possible and it actually seems to be working.. but my problem may be related. On to the problem.

    The widget I am embedding contains a QWebView and this web view is set to use a transparent background. This works great when I do not have that same widget also include another QGraphicsScene. However when I include a QGraphicsScene as a child to my QWebView then the transparent background is no longer transparent and I get video garbage drawn as the background. Here is a screenshot to demonstrate what I mean.. there are two issues going on here. The side on the left shows it working when I do not embed another QGraphicsView the side on the right shows an embedded graphics view, however you should notice the pink box contains the other QGraphicsView which location is not correct (I'll explore that later) and the area with garbage video data is where the QGraphicsView should be drawn.


    It seems almost as if there is a draw order issue but then I don't know why it would order and work just fine when the sub QGraphicsView is not added.

    Any help is greatly appreciated.


  • I am still stuck here but thought I might ask a more specific question regarding blending. For the transparent widget when its working correctly I am using these settings to make my QWidget that hosts a QWebView to maintain a transparent background:

    @QPalette palette = _webView->palette();
    palette.setBrush(QPalette::Base, Qt::transparent);
    _webView->setAttribute(Qt::WA_OpaquePaintEvent, false);
    _webView->setAttribute(Qt::WA_TranslucentBackground, true);
    _webView->setWindowFlags(Qt::ToolTip | Qt::FramelessWindowHint);
    setAttribute(Qt::WA_OpaquePaintEvent, false);
    setAttribute(Qt::WA_TranslucentBackground, true);
    setWindowFlags(Qt::ToolTip | Qt::FramelessWindowHint);@

    Now, once add my additional QGraphicsView (as a child of the QWebView) which is which is doing a whole lot of custom GL calls I suspect the blending states are getting out of alignment with what Qt needs. I am wrapping my GL calls with a begin/end native panting block and I have tested a before and after dump of all OpenGL states I can get with the glGet calls and that does reveal a blending stage change, so I tried putting the gl state to the same as it was before my GL calls but it made no difference.

    My question now is, what might cause this? Is there someplace I could manipulate or look at the GL state right before the widget is drawn? When a QGraphicsScene is drawing embedded widgets in GL modes what QWidget (or QGraphicsProxyWidget) properties empact GL blend modes? How do child widgets get impacted by these blend states?

    I think I am on the right track here to start asking some more specific questions but this is still a little black box to me to know where to begin.


Log in to reply

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.