I want when i check each box, progress bar increase and when i unchecked box, progress bar decreased .
CodePudding user response:
Connect to QCheckBox::stateChanged(int state)
signal, and change the progressbar
value according to signal state
.
Edit
Following the comments, I will update the answer further more. Like I said you need to connect to QCheckBox::stateChanged(int state)
signal from each QCheckBox
you have.
To connect to signal you use:
connect(ui->checkBox, &QCheckBox::stateChanged, this, &MainWindow::Update_ProgressBar);
connect(ui->checkBox_2, &QCheckBox::stateChanged, this, &MainWindow::Update_ProgressBar);
...
And the slot
will be:
void MainWindow::Update_ProgressBar(int value)
{
int currentValue = ui->progressBar->value();
if(value == 0)ui->progressBar->setValue(currentValue - 20);
else ui->progressBar->setValue(currentValue 20);
}