I am using vtkCaptionWidget to annotate the 2D image loaded in qvtkwidget. However once the caption widget is placed on the image QApplication::exit(0) doesn’t work. Even if the window is closed by calling close() function, application runs in the background.
This is my code for caption written in a clickcallback function
auto* iren = static_cast<vtkRenderWindowInteractor*>(caller);
vtkSmartPointer<vtkCoordinate> coordinate = vtkSmartPointer<vtkCoordinate>::New();
coordinate->SetCoordinateSystemToDisplay();
coordinate->SetValue(iren->GetEventPosition()[0],iren->GetEventPosition()[1],0);
double* world = coordinate->GetComputedWorldValue(iren->GetRenderWindow()->GetRenderers()->GetFirstRenderer());
double pos[3] = {world[0], world[1], 0};
std::string str = annotText.toStdString();
const char* cText = str.c_str();
vtkTextProperty *tprop = vtkTextProperty:: New();
tprop->SetFontFamilyToArial();
tprop->SetFontSize(14);
tprop->BoldOn();
tprop->ShadowOn();
tprop->ItalicOn();
tprop->SetColor(1, 1, 1);
vtkNew<vtkCaptionRepresentation> captionRepresentation;
captionRepresentation->GetCaptionActor2D()->GetTextActor()->SetTextScaleMode(1);
captionRepresentation->GetCaptionActor2D()->SetCaptionTextProperty(tprop);
captionRepresentation->GetCaptionActor2D()->SetCaption(cText);
captionRepresentation->GetCaptionActor2D()->BorderOn();
captionRepresentation->GetCaptionActor2D()->ThreeDimensionalLeaderOff();
captionRepresentation->GetCaptionActor2D()->SetMaximumLeaderGlyphSize(10);
//captionRepresentation->GetCaptionActor2D()->GetPositionCoordinate()->SetCoordinateSystemToViewport();
captionRepresentation->SetPosition(0.7,0.3);
captionRepresentation->SetPosition2(0.1,0.03);
captionRepresentation->SetAnchorPosition(pos);
vtkNew<vtkCaptionWidget> captionWidget;
captionWidget->SetInteractor(iren);
captionWidget->SetRepresentation(captionRepresentation);
captionWidget->On();
iren->Start();
This is the code in quit button click
QApplication::exit(0);
ui->~MainWindow();
What could be causing this. This doesn’t arise on placing any other widgets like distance or angle widget.