I am learning vtk example in Qt environment. I tested this example SliderWidget.
I just change the code as below:
sliderWidget->SetInteractor(this->ui->qvtkWidget->GetInteractor());
However, the SliderWidget doesn’t show in the screen. Do I need set something?
Here is the whole code.
vtkSmartPointer<vtkSliderRepresentation2D> sliderRep =
vtkSmartPointer<vtkSliderRepresentation2D>::New();
sliderRep->SetMinimumValue(3.0);
sliderRep->SetMaximumValue(20.0);
sliderRep->SetValue(5.0);
sliderRep->SetTitleText("Sphere Resolution");
// Set color properties:
sliderRep->GetSliderProperty()->SetColor(1, 0, 0);//red
sliderRep->GetTitleProperty()->SetColor(1, 0, 0);//red
sliderRep->GetLabelProperty()->SetColor(1, 0, 0);//red
sliderRep->GetSelectedProperty()->SetColor(0, 1, 0);//green
sliderRep->GetTubeProperty()->SetColor(1, 1, 0);//yellow
sliderRep->GetCapProperty()->SetColor(1, 1, 0);//yellow
sliderRep->GetPoint1Coordinate()->SetCoordinateSystemToDisplay();
sliderRep->GetPoint1Coordinate()->SetValue(40, 40);
sliderRep->GetPoint2Coordinate()->SetCoordinateSystemToDisplay();
sliderRep->GetPoint2Coordinate()->SetValue(100, 40);
vtkSmartPointer<vtkSliderWidget> sliderWidget =
vtkSmartPointer<vtkSliderWidget>::New();
sliderWidget->SetInteractor(this->ui->qvtkWidget->GetInteractor());
sliderWidget->SetRepresentation(sliderRep);
sliderWidget->SetAnimationModeToAnimate();
sliderWidget->EnabledOn();
sliderWidget->On();