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

Elvis Dowson elvis.dowson at mac.com
Tue Oct 21 06:37:47 EDT 2008


Hi,
         I managed to get the VTK off-screen rendering to work, using  
QGraphicsView and QGraphicsScene, but with one exception. It only  
works if I use a normal QWidget (paint engine type = 3 Mac OS  
CoreGraphics).

However, the moment I switch to using QGLWidget with QGraphicsView to  
use OpenGL to render the Qt widgets, nothing gets displayed. Neither  
the QDialog nor the VTK off-screen rendered image. The  
QGraphicsScene::drawBackground() method implements the painting of the  
off-screen images.

If I move the off-screen painting to the  
QGraphicsScene::drawForeground() method, and still use QGLWidget, to  
use OpenGL for rendering the Qt widgets, only the Qt widgets get  
displayed.

So the first issue is for some reason, the painting of off-screen  
images works with a normal QWidget, but the moment I switch to  
QGLWidget, the painting techniques stops working.

You can see this for your self, in the attached project by changing  
the values of the following definitions, to use QGLWidget instead of  
QWidget :

#define QT_GRAPHICSVIEW_USE_QGLWIDGET 1
#define QT_GRAPHICSVIEW_USE_QWIDGET 0




What could be going wrong or preventing me from using QGLWidget to  
render the OpenGL images? Is it because the commands executed in the  
drawBackground method wasn't OpenGL ? Does this mean that if somehow,  
I got the QGLWidget to share the OpenGL context with the  
vtkRenderWindow, VTK will automatically catch and render the VTK  
images using a shared OpenGL context?

Best regards,

Elvis Dowson

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20081021/87c63bb9/attachment.htm>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: vtkOffScreenRenderingTest.zip
Type: application/zip
Size: 24885 bytes
Desc: not available
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20081021/87c63bb9/attachment.zip>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20081021/87c63bb9/attachment-0001.htm>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: VTK offscreen rendering using QGraphicsView and QWidget.jpg
Type: image/jpeg
Size: 33045 bytes
Desc: not available
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20081021/87c63bb9/attachment.jpg>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20081021/87c63bb9/attachment-0002.htm>


More information about the vtkusers mailing list