|  | Home · All Classes · Modules

# QGroupBox Class Reference
[QtGui module]

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

Inherits QWidget.

### Methods

- __init__ (self, QWidget parent = None)
- __init__ (self, QString, QWidget parent = None)
- Qt.Alignment alignment (self)
- changeEvent (self, QEvent)
- childEvent (self, QChildEvent)
- bool event (self, QEvent)
- focusInEvent (self, QFocusEvent)
- initStyleOption (self, QStyleOptionGroupBox)
- bool isCheckable (self)
- bool isChecked (self)
- bool isFlat (self)
- QSize minimumSizeHint (self)
- mouseMoveEvent (self, QMouseEvent)
- mousePressEvent (self, QMouseEvent)
- mouseReleaseEvent (self, QMouseEvent)
- paintEvent (self, QPaintEvent)
- resizeEvent (self, QResizeEvent)
- setAlignment (self, int)
- setCheckable (self, bool)
- setChecked (self, bool)
- setFlat (self, bool)
- setTitle (self, QString)
- QString title (self)

### Qt Signals

- void clicked (bool = 0)
- void toggled (bool)

## 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 QCheckBoxes or QRadioButtons 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.

## Method Documentation

### QGroupBox.__init__ (self, QWidget parent = None)

The parent argument, if not None, causes self to be owned by Qt instead of PyQt.

Constructs a group box widget with the given parent but with no title.

### QGroupBox.__init__ (self, QString, QWidget parent = None)

The parent argument, if not None, causes self to be owned by Qt instead of PyQt.

Constructs a group box with the given title and parent.

### Qt.Alignment QGroupBox.alignment (self)

### QGroupBox.changeEvent (self, QEvent)

Reimplemented from QWidget.changeEvent().

### QGroupBox.childEvent (self, QChildEvent)

Reimplemented from QObject.childEvent().

### bool QGroupBox.event (self, QEvent)

Reimplemented from QObject.event().

### QGroupBox.focusInEvent (self, QFocusEvent)

Reimplemented from QWidget.focusInEvent().

### QGroupBox.initStyleOption (self, QStyleOptionGroupBox)

Initialize option with the values from this QGroupBox. This method is useful for subclasses when they need a QStyleOptionGroupBox, but don't want to fill in all the information themselves.

See also QStyleOption.initFrom().

### bool QGroupBox.isCheckable (self)

### bool QGroupBox.isChecked (self)

### bool QGroupBox.isFlat (self)

### QSize QGroupBox.minimumSizeHint (self)

Reimplemented from QWidget.minimumSizeHint().

### QGroupBox.mouseMoveEvent (self, QMouseEvent)

Reimplemented from QWidget.mouseMoveEvent().

### QGroupBox.mousePressEvent (self, QMouseEvent)

Reimplemented from QWidget.mousePressEvent().

### QGroupBox.mouseReleaseEvent (self, QMouseEvent)

Reimplemented from QWidget.mouseReleaseEvent().

### QGroupBox.paintEvent (self, QPaintEvent)

Reimplemented from QWidget.paintEvent().

### QGroupBox.resizeEvent (self, QResizeEvent)

Reimplemented from QWidget.resizeEvent().

### QGroupBox.setAlignment (self, int)

### QGroupBox.setCheckable (self, bool)

### QGroupBox.setChecked (self, bool)

This method is also a Qt slot with the C++ signature `void setChecked(bool)`.

### QGroupBox.setFlat (self, bool)

### QGroupBox.setTitle (self, QString)

### QString QGroupBox.title (self)

## Qt Signal Documentation

### void clicked (bool = 0)

This is the default overload of this signal.

This signal is emitted when the check box is activated (i.e. pressed down then released while the mouse cursor is inside the button), or when the shortcut key is typed, Notably, this signal is not emitted if you call setChecked().

If the check box is checked checked is true; it is false if the check box is unchecked.

This function was introduced in Qt 4.2.

See also checkable, toggled(), and checked.

### void toggled (bool)

This is the default overload of this signal.

If the group box is checkable, this signal is emitted when the check box is toggled. on is true if the check box is checked; otherwise it is false.

See also checkable.