[vtkusers] Flickering with QVTKWidget

Clinton Stimpson clinton at elemtech.com
Sat Oct 25 11:01:52 EDT 2008


> Hi All,
>
> I have developed a GUI with Qt and I am using the QVTKWidget to 
> display a 2D
> image.
>
> This 2D image cames from a 3D image. I have a slider to control what 
> is the
> slice to be displayed.
>
> The problem is that I am getting a flickering effect every time the 
> image is
> changed.
>
> Here is a piece of code of what I am doing:
>
> void MyGui::moveBar() {
>    ImageType2D::Pointer img =
> myImage->getImage2DFrom3D(horizontalScrollBar->value());
>
>    vtkImageViewer* image_view = vtkImageViewer::New();
>    image_view->SetInput(myImage->convertITKtoVTK(img));
>
>    vtkWidget->SetRenderWindow(image_view->GetRenderWindow());
>
>    image_view->SetColorLevel(138.5);
>    image_view->SetColorWindow(233);
>
>    vtkWidget->show();
> }
>
> This method is called every time the slider is moved.
>
> Does anybody knows how to get rid of this flickering effect?

The flicker comes from re-creating the vtkRenderWindow each time you 
have an image.
Can't you use the same vtkImageViewer instance at all times, and just 
call SetInput when you change the image?
And don't bother calling vtkWidget->SetRenderWindow() and 
vtkWidget->show() each time the slider moves.

Clint





More information about the vtkusers mailing list