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