0
votes

I have a problem with qvtkwidget. I have a cube with the vtkimageplanewidget and i already made the connection between the sliders and them, but I want the slider to change also when I change the planes with the mouse in the qvtkwidget.

How can i do that?

Here's how I connected the slider eith the planes.

SLOT:

void planevolume::SplaneXpixel()
{
    double xvalue=ui->Slider->value();
    planeX->SetSliceIndex(xvalue);
    ui->qvtkWidget->update();
}

and then:

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

What about the opposite? I tried:

SLOT:

void planevolume::planeXSpixel()
{
    double xvalue=planeX->GetSliceIndex();
    ui->Slider->setValue(xvalue);
    ui->qvtkWidget->update();
}

and then:

connect(ui->qvtkWidget, SIGNAL(mouseEvent(QMouseEvent*)), SLOT(planeXSpixel()));

but it won't work, can anyone help me?

2
What won't work? I'd suggest posting a fully compilable example, and explaining what is going wrong.David Doria

2 Answers

1
votes

I believe you are looking for vtkEventQtSlotConnect. Here is an example: http://www.vtk.org/Wiki/VTK/Examples/Cxx/Qt/EventQtSlotConnect

0
votes

If you work with the UI form, right click the slider, choose "Go to slot..." and select the sliderMoved(int) slot. Inside the automated slot created by Qt, it should be on_slider_sliderMoved(int position). just insert your code there. maybe this implementation should help you further:

Displaying DICOM Series using the Qt sliderbar