Hi,
I’m trying to launch VTK widget example in Qt. So I’ve rewriten the code to use it in Qt and I now have something like:
MyMainWindow::MyMainWindow(){
// A renderer and render window
vtkSmartPointer<vtkRenderer> renderer =
vtkSmartPointer<vtkRenderer>::New();
vtkSmartPointer<vtkGenericOpenGLRenderWindow> renderWindow =
vtkSmartPointer<vtkGenericOpenGLRenderWindow>::New();
renderWindow->AddRenderer(renderer);
// An interactor
vtkSmartPointer<vtkRenderWindowInteractor> renderWindowInteractor =
vtkSmartPointer<vtkRenderWindowInteractor>::New();
renderWindowInteractor->SetRenderWindow(renderWindow);
double pos1[3] = {50.0, 200.0, 0.0};
double pos2[3] = {200.0, 20.0, 0.0};
double center[3] = {100.0, 100.0, 0.0};
vtkSmartPointer<vtkAngleRepresentation2D> rep =
vtkSmartPointer<vtkAngleRepresentation2D>::New();
rep->ArcVisibilityOff();
vtkSmartPointer<vtkAngleWidget> angleWidget =
vtkSmartPointer<vtkAngleWidget>::New();
angleWidget->CreateDefaultRepresentation();
angleWidget->SetRepresentation(rep);
angleWidget->SetInteractor(renderWindowInteractor);
// renderWindow->Render();
renderWindowInteractor->Initialize();
// renderWindow->Render();
angleWidget->On(); // This line gives me error in debug mode
rep->SetPoint1DisplayPosition(pos1);
rep->SetPoint2DisplayPosition(pos2);
rep->SetCenterDisplayPosition(center);
rep->Ray1VisibilityOn();
rep->Ray2VisibilityOn();
rep->ArcVisibilityOn();
// Begin mouse interaction
renderWindowInteractor->Start();
QPointer<QVTKOpenGLNativeWidget> vtkWidget = new QVTKOpenGLNativeWidget();
vtkWidget->setRenderWindow(renderWindow);
setCentralWidget(vtkWidget);
}
I also tried other examples where VTK widgets are used but unsuccessfully…
I think there are some secrets when using VTK widgets in Qt.
Could someone explain where is the problem and how solve the problem?
I use VTK 9.0.0 and Qt 5.14.2, Windows 10 x64, MSVC 2017 x64