[SOLVED]Radio button question
-
Hi,
I have a form designed using Qt Designer as shown here.
http://i60.tinypic.com/2wrkvgk.jpg
I group the radio buttons horizontally first and I could select one radio button for every line even after grouping them all together in grid layout.
But at run time, this happens:
http://tinypic.com/view.php?pic=20u7qz5&s=8#.U5ajKPmSwms
Only one radio button can be selected out of all. What I did was to put them in scroll area (because my form is really long) and i have no choice but to group them in a layout. Why is there difference when i design it in Qt Designer and unselectable radio buttons at runtime? And what can i do so that the radio buttons at each line can be selected?
-
You need to turn off "autoExclusive":http://qt-project.org/doc/qt-5/qabstractbutton.html#autoExclusive-prop option.
Please note, however, that the general consensus is that check boxes should be used when many can be selected at once. Radio buttons are meant to be used when only one can be selected.
-
Hi sierdzio,
Is this the right way to do it?
@
QButtonGroup bg;
bg.addButton(ui->radioButton);
ui->radioButton->setChecked(true);
ui->radioButton->autoExclusive(false);
@I get the compilation error:
no matching function for call to "QRadioButton::autoExclusive(bool); -
All property setters in Qt begin with "set":
@
ui->radioButton->setAutoExclusive(false);
@ -
Oh my bad, thanks very much, it works now.