[vtkusers] QVTKWidget and vtkRenderWindowInteractor problem

Clinton Stimpson clinton at elemtech.com
Sat Jul 1 19:24:39 EDT 2006


> hi, all
> I am using Qt3.3+vtk5.0. I have a mainframe and a slaveframe. The
> QVTKWidget is in the slaveframe. By click a button on the mainframe,
> the slaveframe is loaded with data and shown.
> The problem is: when I start the vtkRenderWindowInteractor of the
> slaveframe, the mainframe becomes frozen (all the items in the frame
> can not be seen) while the slaveframe works fine. The mainframe can
> only be accessed again by killing the slaveframe.
> I need the vtkRenderWindowInteractor to connect the
> vtkImagePlaneWidget with the QVTKWidget (in the following simplified
> code it did not show this). How should I implement such that in the
> slaveframe I can interact with the vtkImagePlaneWidget and at the same
> time (of course move the mouse onto the masterframe) I can interact
> with the mainframe as wish.
> The following is the problem code:
>
> mainframe::initialSlaveframe(){
>     vtkRenderer* ren1 = vtkRenderer::New();
>     vtkRenderWindow* renWin1 = vtkRenderWindow::New();
>     renWin1->AddRenderer(ren1);
>     vtkRenderWindowInteractor* iren1 = vtkRenderWindowInteractor::New();
>     iren1->SetRenderWindow(renWin1);
>     iren1->Initialize();
>     iren1->Start();
>     slaveframe->qVTKWidget->SetRenderWindow(renWin1);
> }
>
> Thanks for help.
>
> zl2k
>   

VTK's Win32, X, Carbon, Cocoa, etc.. interactors do NOT work with Qt.
There is a QVTKInteractor that works with Qt.

Your code can be simply done as

    vtkRenderer* ren1 = vtkRenderer::New();
    vtkRenderWindow* renWin1 = slaveframe->qVTKWidget->GetRenderWindow();
    renWin1->AddRenderer(ren1);


You can get the interactor one of two ways.

    vtkRenderWindowInteractor* iren1 = qVTKWidget->GetInteractor();

    vtkRenderWindowInteractor* iren1 = renWin1->GetInteractor();


If you want to create your own interactor, it has to be a QVTKInteractor.

Also, you run the event loop the 'Qt' way, not the VTK way   
QApplication::exec()  instead of vtkRenderWindowInteractor::Start();

Clint




More information about the vtkusers mailing list