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.
First create slots plus()
and minus()
:
public slots:
void plus();
void minus();
Then connect the clicked signal with the respective slot:
connect({your minus QPushButton}, SIGNAL(clicked()) , this, SLOT(minus()));
connect({your plus QPushButton}, SIGNAL(clicked()) , this, SLOT(plus()));
In each slot implement the increase or decrease tasks.
void {your widget}::plus()
{
{your slider}->setValue({your slider}->value()+1);
}
void {your widget}::minus()
{
{your slider}->setValue({your slider}->value()-1);
}