[Interest] How do I get two indepentend radio button groups with QtCreator?

Joerg Desch news at jdesch.de
Mon Jul 18 11:12:52 CEST 2016


Just a silly questions of a Qt beginner... ;-)

I've designed a Qt dialog with QtCreator. To get a "key/value" form, I've 
used a QGridLayout with two columns. To use radio buttons as selection, 
I've placed a QHBoxLayout inside a grid cell and added some QRadioButtons. 
In the end, I have two of these groups in my dialog.

After a first try, I've realized, that the two radio button groups are 
not independent! Selecting a button of the second group unchecks all 
buttons in the first group.

Searching the documentation, I've found QButtonGroup. A thread inside a 
Qt web forum explained how to add radio buttons into these groups.

So far so good. I've placed the radio buttons into two groups. A "select 
members" shows the expected buttons. But running the program still shows 
me the previous behavior. All the buttons are still in one group.
I've played with the "autoExclusive" attribute of the QRadioButton 
elements, but without success.

I checked the generated output too. The source generated by moc adds the 
radio buttons into the QButtonGroup as expected.

Any hints?




More information about the Interest mailing list