|  | Home · Overviews · Examples |

# QGroupBox Class Reference
[com.trolltech.qt.gui module]

The `QGroupBox` widget provides a group box frame with a title. More...

Inherits `QWidget`.

## Detailed Description

The `QGroupBox` widget provides a group box frame with a title.

A group box provides a frame, a title and a keyboard shortcut, and displays various other widgets inside itself. The title is on top, the keyboard shortcut moves keyboard focus to one of the group box's child widgets.

`QGroupBox` also lets you set the title (normally set in the constructor) and the title's alignment. Group boxes can be checkable; child widgets in checkable group boxes are enabled or disabled depending on whether or not the group box is checked.

You can minimize the space consumption of a group box by enabling the flat property. In most styles, enabling this property results in the removal of the left, right and bottom edges of the frame.

`QGroupBox` doesn't automatically lay out the child widgets (which are often `QCheckBox`es or `QRadioButton`s but can be any widgets). The following example shows how we can set up a `QGroupBox` with a layout:

            QGroupBox *groupBox = new QGroupBox(tr("Exclusive Radio Buttons"));

            QRadioButton *radio1 = new QRadioButton(tr("&Radio button 1"));
            QRadioButton *radio2 = new QRadioButton(tr("R&adio button 2"));
            QRadioButton *radio3 = new QRadioButton(tr("Ra&dio button 3"));

            radio1->setChecked(true);

            QVBoxLayout *vbox = new QVBoxLayout;
            vbox->addWidget(radio1);
            vbox->addWidget(radio2);
            vbox->addWidget(radio3);
            vbox->addStretch(1);
            groupBox->setLayout(vbox);

A Windows XP style group box. | A Macintosh style group box. | A Plastique style group box.

See also `QButtonGroup` and Group Box Example.