[vtkusers] flickering when using QT
Clinton Stimpson
clinton at elemtech.com
Mon Oct 16 10:05:02 EDT 2006
> From: "Anja Ende" <anja.ende at googlemail.com>
> Subject: [vtkusers] flickering when using QT
> To: VTK <vtkusers at vtk.org>
>
> Hi everyone,
>
> So, I have managed to render above a QVTKWidget window using QT.
>
> However, there is one nagging problem. So, I have a set of points that I can
> interact with using the mouse and move them around. But whenever I move a
> point around there is a lot of flickering. I am using Qt4 and double
> buffering is on by default.
>
> Hoping that anyone who has more experience using QT with VTk might give some
> advise on how to achieve flicker free rendering.
>
> Cheers,
>
> Anja
Qt does double buffering by default. And returning NULL for paintEngine() tells Qt "hands off" for this QWidget, which means it doesn't do double buffering. The flickering you're seeing is a result of Qt doing double buffering, because you're giving it the QWidget::paintEngine().
To compare with, the QGLWidget creates it's own QPaintEngine, instead of using QWidget::paintEngine(). All paint methods are implemented in OpenGL, and double buffering is probably turned off because it isn't a default paint engine.
Way back during the Qt4 preview, Trolltech said they might make what you're trying to do easier, in Qt 4.1 or later. 4.2 is out and I don't know if they've done anything to help you.
Here's a couple ideas, some without really knowing how well they'd work:
1. Find out how Trolltech was going to let us bypass the double buffer after Qt 4.0. And find a solution based on that. Here's the thread where they said that. http://lists.trolltech.com/qt4-preview-feedback/2005-04/thread00609-0.html
2. In your paintEvent(), do the QVTKWidget::paintEvent and do your painting into a QPixmap, and then combine the two.
3. Do your painting in VTK like everyone else.
4. Implement your own QPaintEngine in terms of VTK, or OpenGL, if you can assume you'll only ever use OpenGL.
5. Put a transparent widget on top of the QVTKWidget and do your painting on that.
Clint
More information about the vtkusers
mailing list