Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. [solved] Problem of uncheck all the Radio buttons within a groupbox
QtWS25 Last Chance

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

Scheduled Pinned Locked Moved General and Desktop
2 Posts 1 Posters 9.8k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • H Offline
    H Offline
    Hareen Laks
    wrote on last edited by
    #1

    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...

    1 Reply Last reply
    0
    • H Offline
      H Offline
      Hareen Laks
      wrote on last edited by
      #2

      I found answer "here":http://stackoverflow.com/questions/1731620/is-there-a-way-to-have-all-radion-buttons-be-unchecked.

      1 Reply Last reply
      0

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved