[vtkusers] Rendering VTK inside a QGLWidget
Clinton Stimpson
clinton at elemtech.com
Wed Oct 5 19:17:57 EDT 2011
On Wednesday, October 05, 2011 04:54:40 pm Paul Rossi wrote:
> Hi all,
>
> I have a problem and i havent been able to fix it.
> i want to use VTK from Qt, and i know that there is the
> nice QVTK module for that.
> My problem is that i have to do my rendering from within a QGLWidget
> (i am using a sort of framework where my views are qglwidgets, and i
> cannot use any other viewer class)
>
> I know it is possible to render vtk from within a QGraphicsView, but i
> still cannot find if or how to render a vtkrenderer from within a
> qglwidget
>
> any suggestion?
>
Try using the vtkGenericOpenGLRenderWindow in VTK 5.8.
You can also see QVTKWidget2 as an example of using it, but depending on what
you are doing, it may be simpler. Or simply use QVTKWidget2 which is derived
from QGLWidget, if that'll fit in your framework.
If you do it yourself, you should at least call in the construction, depending
on how you are going to use it:
renWin->SwapBuffersOff()
in the resize
renWin->SetSize()
in the paintGL()
renWin->PushState()
renWin->OpenGLInit()
renWin->Render()
renWin->PopState()
If you are also mixing calls to QPainter, make sure to call
QPainter::beginNativePainting()/endNativePainting().
There's more to do if you want to use vtkRenderWindowInteractor as well.
--
Clinton Stimpson
Elemental Technologies, Inc
Computational Simulation Software, LLC
www.csimsoft.com
More information about the vtkusers
mailing list