# vtk SliderWidget in Qt environment

**URL:** https://discourse.vtk.org/t/vtk-sliderwidget-in-qt-environment/2761
**Category:** Support
**Created:** [March 5, 2020, 12:44pm UTC](https://discourse.vtk.org/t/vtk-sliderwidget-in-qt-environment/2761 "2020-03-05T12:44:22Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![lyz](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/l/e47774/32.png) [@lyz](https://discourse.vtk.org/u/lyz)
#### Post date: [March 5, 2020, 12:44pm UTC](https://discourse.vtk.org/t/vtk-sliderwidget-in-qt-environment/2761/1 "2020-03-05T12:44:22Z")

</div>

I am learning vtk example in Qt environment. I tested this example [SliderWidget](https://lorensen.github.io/VTKExamples/site/Cxx/Widgets/Slider).

I just change the code as below:

```auto
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.

```auto
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();

```
