QButtonGroup
The QButtonGroup class has been completely redesigned in Qt 4. For compatibility, the oldQButtonGroup class has been renamed Q3ButtonGroup and has been moved to Qt3Support. Likewise, the QHButtonGroup and QVButtonGroup convenience subclasses have been renamed Q3HButtonGroupand Q3VButtonGroup and moved to the Qt3Support library.
The old QButtonGroup, as well as Q3ButtonGroup, can be used in two ways:
- The button group is the parent widget of a number of buttons, i.e. the button group is the parent argument in the button constructor. The buttons are assigned identifiers 0, 1, 2, etc., in the order they are created. A Q3ButtonGroup can display a frame and a title because it inherits Q3GroupBox.
- The button group is an invisible widget and the contained buttons have some other parent widget. In this usage, each button must be manually inserted, usingQ3ButtonGroup::insert(), into the button group and given an ID number.
Unlike Q3ButtonGroup, the new QButtonGroup doesn't inherit QWidget. It is very similar to a "hiddenQ3ButtonGroup".
If you use a Q3ButtonGroup, Q3HButtonGroup, or Q3VButtonGroup as a widget and want to port to Qt 4, you can replace it with QGroupBox. In Qt 4, radio buttons with the same parent are automatically part of an exclusive group, so you normally don't need to do anything else. See also the section on QGroupBox below.
See Virtual Functions for a list of QButtonGroup virtual member functions in Qt 3 that are no longer virtual in Qt 4.