
Originally Posted by
anda_skoa
Instead of that you connect the valueChanged(int) signal to a slot and the do a switch on the value passed to that slot.
For each value the respective case statement will then call the appropriate slot.
Cheers,
_
It makes some sense now. Thanks. Got this done with some help.
slider->setRange(0, 4);
connect(slider, SIGNAL(valueChanged(int)), SLOT(onSliderValueChanged(int)));
void guiSlider::onSliderValueChanged(int value)
{
switch (value)
{
case 0:
return on_pushButton_clicked();
case 1:
return on_pushButton_1_clicked();
case 2:
return on_pushButton_2_clicked();
case 3:
return on_pushButton_3_clicked();
case 4:
return on_pushButton_4_clicked() ;
}
void guiSlider::on_pushButton_clicked()
{
slider->blockSignals(true);
slider->setValue(0);
slider->blockSignals(false);
}
slider->setRange(0, 4);
connect(slider, SIGNAL(valueChanged(int)), SLOT(onSliderValueChanged(int)));
void guiSlider::onSliderValueChanged(int value)
{
switch (value)
{
case 0:
return on_pushButton_clicked();
case 1:
return on_pushButton_1_clicked();
case 2:
return on_pushButton_2_clicked();
case 3:
return on_pushButton_3_clicked();
case 4:
return on_pushButton_4_clicked() ;
}
void guiSlider::on_pushButton_clicked()
{
slider->blockSignals(true);
slider->setValue(0);
slider->blockSignals(false);
}
To copy to clipboard, switch view to plain text mode
Thats Part of the code. It works now, however the slider seems to respond at times and does not respond at times. For instance, if I move it to say 10, it works but then stays there regardless of moving the sllider. All of a sudden, it then jumps to 30 or 40. Any idea why?
Thanks again!
Bookmarks