when setchecked(0), one of the buttonGroup is always checked(solved)
-
In the code below, when pushButton43 get clicked, there is always one button checked. i need all the button to be unchecked. What is the problem?
'''
QButtonGroup* ButtonGroup = new QButtonGroup(this);
ButtonGroup->addButton(ui->pushButton11);
ButtonGroup->addButton(ui->pushButton12);
ButtonGroup->addButton(ui->pushButton13);
ButtonGroup->addButton(ui->pushButton14);ui->pushButton11->setAutoExclusive(true); ui->pushButton12->setAutoExclusive(true); ui->pushButton13->setAutoExclusive(true); ui->pushButton14->setAutoExclusive(true);
void MainWindow::on_pushButton43_clicked()
{
ui->pushButton11->setChecked(0);
ui->pushButton12->setChecked(0);
ui->pushButton13->setChecked(0);
ui->pushButton14->setChecked(0);
} -
In the code below, when pushButton43 get clicked, there is always one button checked. i need all the button to be unchecked. What is the problem?
'''
QButtonGroup* ButtonGroup = new QButtonGroup(this);
ButtonGroup->addButton(ui->pushButton11);
ButtonGroup->addButton(ui->pushButton12);
ButtonGroup->addButton(ui->pushButton13);
ButtonGroup->addButton(ui->pushButton14);ui->pushButton11->setAutoExclusive(true); ui->pushButton12->setAutoExclusive(true); ui->pushButton13->setAutoExclusive(true); ui->pushButton14->setAutoExclusive(true);
void MainWindow::on_pushButton43_clicked()
{
ui->pushButton11->setChecked(0);
ui->pushButton12->setChecked(0);
ui->pushButton13->setChecked(0);
ui->pushButton14->setChecked(0);
}@houmingc
Hi and welcome to devnetThat seems the intended behaviour of a QGroupBox it says in the detailed description:
An exclusive button group switches off all checkable (toggle) buttons except the one that has been clicked. By default, a button group is exclusive.The behaviour stems from the exclusive property
-
@houmingc
Hi and welcome to devnetThat seems the intended behaviour of a QGroupBox it says in the detailed description:
An exclusive button group switches off all checkable (toggle) buttons except the one that has been clicked. By default, a button group is exclusive.The behaviour stems from the exclusive property