Reputation: 4136
I have a little problem that i think it's easy so get a solution, but i've come to the point of trying everything and still not working. I'm sure it something simple, so i'm asking help as i can't figure it out on my own.
I have a qvtkwidget on the centralwidget and it has no problem.
the problem is that every time i run the program it rends another box apart from the interface.
here's the part of my code that matters for this issue.
// Create renderer
ren= vtkRenderer::New();
ren->AddActor(outlineActor);
ren->SetBackground(0.1,0.1,0.3);
// Drawing some X,Y,Z axes
axes= vtkCubeAxesActor2D::New();
//more stuff
ren->AddViewProp(axes);
ren->ResetCamera();
// Create a window for the renderer
renWin= vtkRenderWindow::New();
renWin->AddRenderer(ren);
// Set an user interface interactor for the render window
iren= vtkRenderWindowInteractor::New();
iren->SetRenderWindow(renWin);
style = vtkInteractorStyleTrackballCamera::New();
iren->SetInteractorStyle(style);
// Create a inicial camera view
vtkCamera *inicam= ren->GetActiveCamera();
inicam->Zoom(1);
inicam->SetViewUp(0, 0, 0);
inicam->Azimuth(45);
ren->ResetCameraClippingRange();
// Start the initialization and rendering
renWin->Render();
// Assign the rendering window to the qvtkwidget
ui->qvtkWidget->SetRenderWindow(renWin);
if someone as any idea about this i would appreciate.
Upvotes: 2
Views: 2389
Reputation: 787
QVTKWidget already has an interactor. So use that one instead:
auto interactorStyle = vtkSmartPointer<TestInteractorStyle>::New();
QVTKInteractor* interactor = widget->GetInteractor();
interactor->SetInteractorStyle(interactorStyle);
Upvotes: 1
Reputation: 4136
after seeing the example i got it to work.
ui->qvtkWidget->GetRenderWindow()->AddRenderer(ren);
Upvotes: 0