How one QSlider move the other 3 QSliders ?
-
You have to set how exactly the other Sliders gonna move, when your RBG-Slider was moved, but in general something like this should work:
connect(slider_rgb, &QSlider::valueChanged, this, &QDialog::calcSliderVal); // Connect to a slot where you calculate and set the value of the other sliders
If you want to move them in the same way as the RGB slider (which makes no sense in your case), you just connect the
valueChanged(int val)
-Signal to thesetValue(int val)
- slot -
One possible way is to store the current slider value in a member var and take this value as reference when the value changes.
Or you try this: https://doc.qt.io/qt-5/qabstractslider.html#actionTriggered
This signal is emitted, whenever the slider changes (not the value).
There is also this (https://doc.qt.io/qt-5/qabstractslider.html#sliderMoved) but it only gets emitted when you move the slider with your mouse, not when the slider moves by using the keyboard. -
@pl45m4 OK, actionTriggered is the signal before move !
int ov = 0; connect(slider, &QSlider::actionTriggered, [&](){ ov = slider->value(); }); connect(slider, &QSlider::valueChanged, [&](int v){ sliderR->setValue(sliderR->value() + v - ov); sliderG->setValue(sliderG->value() + v - ov); sliderB->setValue(sliderB->value() + v - ov); });