[vtkusers] Using VTK widgets in Qt renderers

David Doria daviddoria+vtk at gmail.com
Wed Feb 10 22:06:48 EST 2010


>
> 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...

Thanks,

David
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20100210/455a21a6/attachment.htm>


More information about the vtkusers mailing list