I'm using QGraphicsView with a viewport set to a QGLWidget. In addition to that, I'm overriding the virtual drawBackground, drawForeground and drawItems-methods from QGraphicsView to implement custom painting using OpenGL, as recommended.
I know I could also paint using the OpenGL painter engine, and I'm actually doing that as well, but I need to render things myself as well (specifically 3d items, but also 2d things that cannot be rendered using the Qt OpenGL painter engine because it requires acces to textures from fragment programs and some more random voodoo magic).
The QGLWidget, set as viewport for QGraphicsView, has its autoFillBackground property set to false. However, the colorbuffer (from the QGLWidget) is still getting cleared to white each frame.
Does someone know how I can make QGraphicsView, or the viewport widget (QGLWidget) stop clearing my colorbuffer each time? What I'm basically looking for is that Qt leaves my viewport background alone before and after those overridden drawing calls. When I render something in the viewport using OpenGL, I'd like it to stay there until the next frame update, unless I glClear it myself. Just like it would work when using a QGLWidget alone and no autoFillBackground.
I've done some research on where the white clear seems to be coming from as well. When I re-implemented the paintEvent, I noticed how the view was still going white at each frame update, even though I didn't do much more than calling those overridden methods (drawBackground, etc) which do not clear the view at all.
As far as I can see it's not just the color buffer that gets cleared to white, the depth buffer seems to be cleared automatically as well. Unfortunately, that's (again) not what I'm looking for. I would like to have full control over it between frame updates without having Qt clear it for me.
However, after a few days of searching around in the Qt source code, I really can't find anything that would do something like this. There's no background color, there's no background cache, there's simply nothing, but it keeps clearing the background...
Thanks for any suggestions and/or help
Bookmarks