I have two push buttons labeled with +
and -
probably, I need to increase and decrease the values of the slider using these push buttons, Please help me to code this function.
Can we connect QPushButton to change values of QSlider?
1.3k views Asked by Yana At
2
There are 2 answers
0
On
Alternatively, with a C++11 capable environment, with lambdas instead of new slots
connect(minusButton, &QPushButton::clicked, slider,
[slider] () { slider->setValue(slider->value() - 1 );});
connect(plusButton, &QPushButton::clicked, slider,
[slider] () { slider->setValue(slider->value() + 1 );});
First create slots
plus()
andminus()
:Then connect the clicked signal with the respective slot:
In each slot implement the increase or decrease tasks.