[vtkusers] VTK and Qt 4.0.1 using QVTKWidget
Clinton Stimpson
clinton at elemtech.com
Wed Sep 7 23:42:09 EDT 2005
> Date: Wed, 7 Sep 2005 15:15:58 +0200 (CEST)
> From: Andr? Huisman <ahuisman at cs.uu.nl>
> Subject: [vtkusers] VTK and Qt 4.0.1 using QVTKWidget
> To: vtkusers at vtk.org
>
> Dear vtk and Qt-users,
>
> Until now I spend lots of time setting up my application using Qt 4.0.(1)
> in combination with ITK and VTK. I'm using the ITK export filter and the
> VTK import filter, everything works fine. I can create a vtkImageViewer
> object and I'm able to see the read image. I can also create an ImageActor
> and add that to the renderer, than I get an OpenGL window containing the
> image. No problem. But now I want the window to be a subwindow (mdi child)
> of my Qt application by subclassing QVTKWidget, everything works fine
> using the following code (when I use this code in a class that is not a
> subclass of QVTKWidget it works):
> vtkImageActor* actor = vtkImageActor::New();
> vtkImageData* data = importer->import();
> actor->SetInput(data);
> data->SetScalarTypeToUnsignedChar();
>
> vtkRenderer* renderer = vtkRenderer::New();
> vtkRenderWindowInteractor* iren = vtkRenderWindowInteractor::New();
This creates a vtkWin32RenderWindowInteractor which isn't compatible
with Qt. Use the one that QVTKWidget creates automatically. Or if you
want to
explicitly make it:
vtkRenderWindowInteractor* iren = QVTKInteractor::New();
Get back with me if the above change doesn't fix your mdi problem.
> iren->SetRenderWindow(this->GetRenderWindow());
> renderer->AddActor(actor);
> renderer->SetBackground(0.4392, 0.5020, 0.5647);
> this->GetRenderWindow()->AddRenderer(renderer);
>
> iren->Start();
> renderer->Render();
This render isn't necessary. It happens when you do a show().
> show();
>
> Can someone please help me? I'm using the Microsoft Visual C++ 7.1
> compiler, VTK CVS version (approx. 5 days old).
>
> Thank you very much in advance!
>
> André Huisman
> Dep. of pathology, University Medical Center Utrecht, the Netherlands
More information about the vtkusers
mailing list