0

I have a qwtslider and I want to get the value to apply on a vtkImagePlaneWidget, but i can't figure out how to do this. I've been using getValue() but it won't work.

I have the function to transfer it:

void planevolume::SplaneX()
{
    double xvalue=ui->Slider->getValue();// this does not work
    planeX->SetSliceIndex(xvalue);
    ui->qvtkWidget->update();

that will work as a slot, and

// X Slider
      ui->doubleSpinBox->setDecimals(0);
      ui->doubleSpinBox->setMaximum(xmax);
      ui->doubleSpinBox->setSingleStep(1.0);
      ui->doubleSpinBox->setValue((xmax-xmin)/2.0);
      ui->Slider->setRange(xmin, xmax, 1.0);
      ui->Slider->setScale(xmin, xmax+1.0, (xmax+1.0)/4.0);
      ui->Slider->setValue((xmax-xmin)/2.0);
      connect(ui->Slider, SIGNAL(valueChanged(double)), ui->doubleSpinBox, SLOT(setValue(double)));
      connect(ui->doubleSpinBox, SIGNAL(valueChanged(double)), ui->Slider, SLOT(setValue(double)));

connect(ui->Slider, SIGNAL(valueChanged(double)), this, SLOT(SplaneX()));

how can i do it? does anyone has any idea?

SamuelNLP
  • 4,038
  • 9
  • 59
  • 102

2 Answers2

3

Can you compile this code?

double xvalue=ui->Slider->getValue();// this does not work

you must write:

double xvalue=ui->Slider->value();

metet
  • 81
  • 2
1

Are you aware that vtkImagePlaneWidget::SetSliceIndex takes int as a parameter, not double? What range is your xmin and xmax? Default conversion of double to int will truncate all your fractional stepping (like 1/4th of slider step i see). Also you are connecting to non-existent signals and slots on QDoubleSpinBox. setValue and valueChanged take int as parameter, not double.

Pavel Zdenek
  • 7,146
  • 1
  • 23
  • 38