[solved] Forbid user to uncheck all QRadioButtons when there is only one button.
Not sure the titles is clear enough.
I insert a random number of QRadioButtons in a layout and would like to have one and only one checked.
It is the standard behavior of QRadioButtons (thanks to the autoExclusive property) except when there is only one button.
In that case it is possible to uncheck the button.
Is this a bug or a feature? How do I get around this?
Maybe "there":http://doc.qt.nokia.com/4.7/qgroupbox.html is some help.
I already have the manual, thanks. What do you suggest?
This is a link to "QGroupBox":http://doc.qt.nokia.com/4.7/qgroupbox.html . It was not just a link to the manual.
OK, by rereading your post I think I got your point.
However, with QGroupBox you could watch the "clicked()":http://doc.qt.nokia.com/4.7/qgroupbox.html#clicked signal. If there is only one radio button, then you have to set it again, if unset.
However, I guess you do not have the problem only with one radio button. What is happening, if uncheck the only button of several buttons checked?
Please stop linking to the documentation randomly.
It works fine with multiple buttons (you can't uncheck a button), problem appears only with a single button.
You can make the radio button uncheckable with a [[Doc:QButtonGroup]]:
QButtonGroup *bg = new QButtonGroup(this);
Thanks Volker. It works!
I find it weird that the autoExclusive property mimic the behavior of buttons in a group, except when there is only one radio button.