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

Elvis Dowson elvis.dowson at mac.com
Wed Oct 15 13:59:35 EDT 2008


Hi,
          I just went through the thread, and I just want to make sure  
that I have understood the situation correctly. I'm new to Qt and  
haven't used it before.

Question 01: Is the approach that you have outlined, different from  
what the original Trolltech article talks about?

The Trolltech article talked about using a QGLWidget instead of the  
QWidget with QGraphicsView.

Now, QVTKWidget uses QWidget and not QGLWidget. QGLWidget has two  
options, one using a painter engine and the other using OpenGL. The  
current implementation of QVTKWidget copies RGBA pixel data to the  
rendering surface attached to QWidget.

In the sample code that you developed, you created a way to blend the  
pixels generated from Qt into VTK's render window.

Question 02: Isn't there a performance overhead, plus future  
maintenance issue with respect to Trolltech improving the performance  
of their approach to be gained here, if you subclass QVTKWidget from  
QGLWidget and use OpenGL instead of the Painter engine?

Thus, one one hand, you can get rid of one level of indirection from  
the VTK side, and directly connect to the Qt supplied OpenGL rendering  
context, rather than adding one level of indirection by copying pixel  
data.

On the other hand, Trolltech may continue to improve the performance  
of their technique in subsequent releases, so if we stick to their  
suggestion of using QGLWidget with QGraphicsView, we will be  
compatible with and be able to take advantage of performance  
improvements with time.

So, can't we just locate where the generation of the VTK OpenGL  
commands end, just before generating the pixel data, and then pipe  
that to a QVTKWidget::drawBackground() method, instead of the current  
QVTKWidget::paintEvent() method?

Do you think this approach will improve the performance of the  
implementation?


Best regards,

Elvis Dowson


On Oct 15, 2008, at 8:23 PM, Clinton Stimpson wrote:

>
> The solution is to implement a QPaintEngine for the QVTKWidget.   
> Then its almost a drop-in replacement for QGLWidget in those  
> examples you're looking at.
>
> This has been discussed before, and here's the end of that last  
> thread.
> http://www.vtk.org/pipermail/vtkusers/2008-August/096696.html
> There's some rudimentary sample code included that demonstrates what  
> you're after.
>
> The sample code needs to be improved before it can be included into  
> VTK, and preferably without calling OpenGL directly.  Hopefully VTK  
> has enough abstract apis to make that possible.  I'd work on it some  
> more, but haven't got the resources to.
>
> Clint
>
> On Oct 15, 2008, at 10:00 AM, vtkusers-request at vtk.org wrote:

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20081015/780189e0/attachment.htm>


More information about the vtkusers mailing list