QRadioButton and QGroupBox
-
I was previously using a QButtonGroup and when using this the group function of the radio button does return the group, however this isn't the case when using QGroupBox. I understand from searching online that QGroupBox replaces QButtonGroup. Am I wrong...again?
-
@SPlatten
QGroupBox
does not requireQButtonGroup
.QGroupBox
is a visual element. You can visit all widgets inside it if you wish.QButtonGroup
is a logical element. It does not render anything to the screen. It is used purely to group and access a bunch of widgets in a logical fashion. It only accepts radiobuttons/checkboxes, and is principally convenient for dealing with them where you only want one element in the group to be checked.[I forgot to say: If it suits your coding, there is nothing to stop you having a
QGroupBox
(for visuals) and aQButtonGroup
(for logical handling) if you wish. The latter makes it easier to address the child elements than in the former, though you can manage without it and deal with the group box's children instead.] -
@SPlatten For example: you lay out 5 radio buttons in a group box: 3 are mutually exclusive and the other two are the same. In this case, you need two qbuttongroups for the three and two radio buttons. If all five are mutually exclusive, qbuttongroup is not needed.
The buttons in a button group are usually checkable QPushButtons, QCheckBoxes (normally for non-exclusive button groups), or QRadioButtons.
https://doc.qt.io/qt-5/qbuttongroup.html#details