[vtkusers] Using VTK widgets in Qt renderers
Clinton Stimpson
clinton at elemtech.com
Wed Feb 10 22:16:22 EST 2010
On Feb 10, 2010, at 8:06 PM, David Doria wrote:
> This works for me.
>
>
> int main(int argc, char** argv)
> {
> QApplication app(argc, argv);
> QVTKWidget w;
> w.resize(400,400);
> vtkSmartPointer<vtkRenderer> ren = vtkSmartPointer<vtkRenderer>::New();
> w.GetRenderWindow()->AddRenderer(ren);
> vtkRenderWindowInteractor* iren = w.GetInteractor();
> vtkSmartPointer<vtkBorderWidget> border = vtkSmartPointer<vtkBorderWidget>::New();
> border->SetInteractor(iren);
> border->SetResizable(1);
> border->On();
> w.show();
> return app.exec();
> }
>
>
> Clint
>
> Strange... that works for me too. What isn't working is that same code but using a QVTKWidget that is on a form made in the Qt Designer (so instantiated from a .ui file).
>
>
> vtkSmartPointer<vtkRenderer> rightRenderer =
> vtkSmartPointer<vtkRenderer>::New();
>
> // Add Actor to renderer
> rightRenderer->AddActor(cubeActor);
>
> // VTK/Qt wedded
> this->ui->qvtkWidgetRight->GetRenderWindow()->AddRenderer(rightRenderer);
>
> //add a border widget to the right renderer
> vtkSmartPointer<vtkBorderWidget> borderWidget =
> vtkSmartPointer<vtkBorderWidget>::New();
> borderWidget->SetInteractor(this->ui->qvtkWidgetRight->GetInteractor());
> borderWidget->On();
>
> The cube shows up, so the renderer is setup correctly, but still no border widget ??
>
> Here is the complete example:
> http://www.vtk.org/Wiki/VTK/Examples/Qt/BorderWidget
>
> Maybe there is something wrong with the .ui file? It seems like everything is ok though since it compiles and I can interact with the cube...
That is because you're deleting the border widget at the end of the SimpleView constructor. In other words, the smart pointer is going out of scope.
Clint
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20100210/3b622ad1/attachment.htm>
More information about the vtkusers
mailing list