[vtkusers] How to put Qt widgets on top of a VTK OpenGL scene

Elvis Dowson elvis.dowson at mac.com
Thu Oct 16 23:19:43 EDT 2008


Hi Clint,
                     I was just checking on OpenGL contexts. The  
QGLContext class can take a paint device as a parameter, as described  
here: Qt Toolkit - QGLContext Class

You could also set up overlay and underlay planes in OpenGL.

If Mac OS X implementation of OpenGL supports overlay and underlay  
planes, we could get the VTK scene to draw into the underlay plan and  
the Qt scene to draw into the overlay plane. This would fit in nicely  
with the Trolltech suggestions to use drawBackground(). Since we are  
not going to use Qt for generating an OpenGL scene, we don't have to  
do any OpenGL stuff in drawBackground().

So, in order of trying this out,
a. somehow get VTK to render onto the QVTKWidget, that is now  
subclassed from QGLWidget, using single buffering like you suggested
b. get the Qt scene with the widgets to render onto the OpenGL overlay  
plane. get the VTK scene to render onto the OpenGL underlay plane.

Perhaps a way out would  be to create two separate OpenGL rendering  
contexts, one targeting the OpenGL overlay plane and the other  
targeting the OpenGL underlay plane. This will help composite the  
OpenGL scene, perhaps without resorting to a pixel merge?

I'm just guessing here and the above assumptions need to be validated.

Best regards,

Elvis Dowson

On Oct 16, 2008, at 11:46 PM, Clinton Stimpson wrote:

>
> What you should try to do is get QGLWidget and VTK to share the same  
> context, so that you don't have to do any merging of any sort.  I  
> don't know how to do that, or know if that is possible with the APIs  
> you're given.  As a first step to attempt that, I suggest turning  
> double buffering off in both QGLWidget and vtkRenderWindow.
>
> Clint

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20081017/3f290201/attachment.htm>


More information about the vtkusers mailing list