Search code examples
qtqt5qwt

Can two QwtSlider's update the same value?


I'd like for slider_A to increment the variable tmp with steps of 100, and slider_B to += steps of 1 to the tmp.

This way, if having a range of 1000 in slider_A (and I don't want to have to try to control hundreds of ticks), I can move slider_A seven steps (value 700), and slider_B (range 0-100), 5 steps giving me the value 705.

I'm using Qt5. Thoughts?


Solution

  • There is no problem at all.

    Simply connect both slider's valueChanged() signals to a handler function that does a value = slider1->value() + slider2->value();. You don't necessarily have to use the emited value, so it doesn't matter which slider emits it since you do the summing explicitly. You can have as many sliders as you want.

    If you insist on using an emitted value, then implement your own signal and emit the sum value.