[Qt-interest] Drawing two QGraphicsScenes on one QGLWidget

Samuel Rødal sroedal at trolltech.com
Fri Jan 16 08:53:13 CET 2009


Nick Spacek wrote:
> Hello,
> 
> I'm trying to figure out the best way to draw two different 
> QGraphicsScene over top of eachother. I want to be able to blend and 
> transition them together, something like what is done here: 
> http://daniel.molkentin.de/blog/archives/95-Leveraging-Qt-For-Smooth-Transition-Effects.html
> 
> Well, attaching two scenes to a single view doesn't work (obviously). 
> Two different views can't both have their viewport set to the same GL 
> widget. To be able to blend like the example above, I would need to set 
> the opacity of the GL painter between the drawing of each scene.
> 
> Thanks for any suggestions!

Hi,

You could use QGraphicsView::render() in order to render your two views 
into separate pixelbuffers/frame buffer objects. Then you could blend 
these together into the QGLWidget using texture drawing.

If you want both graphics scenes to be interactive (being able to 
select/move items etc) then I don't see a good solution for you. One 
approach could be to embed one QGraphicsView in another by adding it as 
a proxy widget. If only one (or none) needs to be interactive you could 
make the QGLWidget the viewport of that one and draw the other one using 
offscreen rendering and texture drawing either in 
QGraphicsView::drawBackground() or QGraphicsView::drawForeground() 
depending on whether it should be on blended below or on top.

--
Samuel



More information about the Qt-interest-old mailing list