[solved] Problem of uncheck all the Radio buttons within a groupbox



  • Hi all,

    I have a groupbox with property 'checkable' equal to true. It contains 3 RadioButtons.
    I need to uncheck all RadioButtons when user unchecked the groupbox.

    So I used following method.

    @void MyPropertiesWidget::on_groupBox_toggled(bool checked)
    {
    if (checked)
    {
    pp->setFactor("1");

    }
    else
    {
    
        foreach(QRadioButton *rb,ui->groupBox->findChildren<QRadioButton *>())
        {
            rb->setChecked(false);
    
            qDebug() << rb->text() << rb->isChecked();
        }
        pp->setFactor("0");
    }
    

    }@

    But after going through the foreach loop it give me following results.

    "1" true
    "2" false
    "3" false

    Moreover, those 3 buttons own or a button group. It's buttonclicked SIGNAL connect to following SLOT.

    @void MyPropertiesWidget::setFactor(QAbstractButton *clicked_button)
    {
    pp->setFactor(clicked_button->text());
    }@

    Can anyone help me?

    Thanks in advance...




Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.