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. managing radio buttons

managing radio buttons

Scheduled Pinned Locked Moved Solved General and Desktop
4 Posts 3 Posters 818 Views 3 Watching
  • 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.
  • mzimmersM Offline
    mzimmersM Offline
    mzimmers
    wrote on last edited by
    #1

    Hi all -

    I'm writing a program that's using a few radio buttons. The way I'd like this to work, is that the buttons will change not only on user entry, but also from remote updates.

    I'm currently using setDown(), like this:

            switch (p)
            {
            case LEDC_SOLID_OFF:
                ui->radioButton_off->setDown(true);
                break;
            case LEDC_SOLID_ON:
                ui->radioButton_on->setDown(true);
                break;
            case LEDC_FLASH_SLOW:
                ui->radioButton_slowflash->setDown(true);
                break;
           .
           .
           .
            }
    

    This approach seems to be functional, but it's somewhat unpredictable. I now notice when I push a button from the UI that the former selection is now a blue-filled circle (instead of an empty black circle). Do I need to set the former button as well (using false instead of true)? And if so, am I doing this right, or is there an easier method?

    sierdzioS raven-worxR 2 Replies Last reply
    0
    • mzimmersM mzimmers

      Hi all -

      I'm writing a program that's using a few radio buttons. The way I'd like this to work, is that the buttons will change not only on user entry, but also from remote updates.

      I'm currently using setDown(), like this:

              switch (p)
              {
              case LEDC_SOLID_OFF:
                  ui->radioButton_off->setDown(true);
                  break;
              case LEDC_SOLID_ON:
                  ui->radioButton_on->setDown(true);
                  break;
              case LEDC_FLASH_SLOW:
                  ui->radioButton_slowflash->setDown(true);
                  break;
             .
             .
             .
              }
      

      This approach seems to be functional, but it's somewhat unpredictable. I now notice when I push a button from the UI that the former selection is now a blue-filled circle (instead of an empty black circle). Do I need to set the former button as well (using false instead of true)? And if so, am I doing this right, or is there an easier method?

      sierdzioS Offline
      sierdzioS Offline
      sierdzio
      Moderators
      wrote on last edited by
      #2

      @mzimmers said in managing radio buttons:

      Do I need to set the former button as well (using false instead of true)?

      If your buttons are auto-exclusive then it should not be necessary. If you need to tweak that exclusivity, look into QButtonGroup.

      Although to be honest, what you describe (the blue circle) sounds like a Qt bug to me.

      (Z(:^

      1 Reply Last reply
      3
      • mzimmersM mzimmers

        Hi all -

        I'm writing a program that's using a few radio buttons. The way I'd like this to work, is that the buttons will change not only on user entry, but also from remote updates.

        I'm currently using setDown(), like this:

                switch (p)
                {
                case LEDC_SOLID_OFF:
                    ui->radioButton_off->setDown(true);
                    break;
                case LEDC_SOLID_ON:
                    ui->radioButton_on->setDown(true);
                    break;
                case LEDC_FLASH_SLOW:
                    ui->radioButton_slowflash->setDown(true);
                    break;
               .
               .
               .
                }
        

        This approach seems to be functional, but it's somewhat unpredictable. I now notice when I push a button from the UI that the former selection is now a blue-filled circle (instead of an empty black circle). Do I need to set the former button as well (using false instead of true)? And if so, am I doing this right, or is there an easier method?

        raven-worxR Offline
        raven-worxR Offline
        raven-worx
        Moderators
        wrote on last edited by
        #3

        @mzimmers
        setDown() is not the correct method to use, but setChecked() is.

        If you want to automatically set all other buttons to false when one turns to true use a QButtonGroup as @sierdzio suggested.

        --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
        If you have a question please use the forum so others can benefit from the solution in the future

        1 Reply Last reply
        5
        • mzimmersM Offline
          mzimmersM Offline
          mzimmers
          wrote on last edited by
          #4

          Thank you both. I've changed setDown to setChecked, and it does work better. I'm holding off on adding the QButtonGroup, as you pointed out that QRadioButtons are autoexclusive by default.

          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