[vtkusers] Using VTK widgets in Qt renderers

Wagner Sales wsales at gmail.com
Mon Feb 8 15:24:01 EST 2010


Hi David,

May be you are forgiving the interactor. The following code works fine
to me ( are in a widget constructor ):

        Widget = new QVTKWidget(this);
        WidgetLayout->addWidget(Widget); // my layout
        vtkRenderWindowInteractor *Inter = Widget->GetInteractor();
        Inter->SetRenderWindow(Widget->GetRenderWindow()); // <------
may be this are your problem?

        vtkRenderer *ren = vtkRenderer::New();
	Connector = vtkEventQtSlotConnect::New();
	// connects the interactor to default slots

       // some connections I need. you not are asking for this, but I
think can useful
	Connector->Connect(Inter,
vtkCommand::LeftButtonPressEvent,this,SLOT(OnMouseLeftPressedEvent(vtkObject*)));
        Connector->Connect(Inter,
vtkCommand::LeftButtonReleaseEvent,this,SLOT(OnMouseLeftReleasedEvent(vtkObject*)));

        Widget->GetRenderWindow()->AddRenderer(ren);
        ren->Delete();

Regards,

Wagner


2010/2/8 David Doria <daviddoria+vtk at gmail.com>:
> Is there a trick to turning on widgets in a Qt renderer?
> I tried the normal code (below) I use to turn on a widget, but it does not
> appear in the renderer:
>  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->GetRenderWindow()->GetInteractor());
>
>   static_cast<vtkBorderRepresentation*>(borderWidget->GetRepresentation())->GetBorderProperty()->SetColor(1,0,0);
> //red
>
>   borderWidget->SelectableOff();
>     vtkSmartPointer<BorderCallback> borderCallback =
>       vtkSmartPointer<BorderCallback>::New();
>
>   borderWidget->AddObserver(vtkCommand::InteractionEvent,borderCallback);
>
>   borderWidget->On();
> Is there something special that must be done to get them to work inside a Qt
> render window?
> Thanks,
>
> David
>
> _______________________________________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.html
>
> Please keep messages on-topic and check the VTK FAQ at:
> http://www.vtk.org/Wiki/VTK_FAQ
>
> Follow this link to subscribe/unsubscribe:
> http://www.vtk.org/mailman/listinfo/vtkusers
>
>



More information about the vtkusers mailing list