Table Of Contents

Previous topic

QLabel

Next topic

QFocusFrame

QGroupBox

Inheritance diagram of QGroupBox

Synopsis

Functions

Slots

Signals

Detailed Description

The PySide.QtGui.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.

PySide.QtGui.QGroupBox also lets you set the PySide.QtGui.QGroupBox.title() (normally set in the constructor) and the title’s PySide.QtGui.QGroupBox.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.

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

groupBox = QGroupBox("Exclusive Radio Buttons")

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

radio1.setChecked(True)


vbox = QVBoxLayout()
vbox.addWidget(radio1)
vbox.addWidget(radio2)
vbox.addWidget(radio3)
vbox.addStretch(1)
groupBox.setLayout(vbox)
../../_images/windowsxp-groupbox.png ../../_images/macintosh-groupbox.png ../../_images/plastique-groupbox.png
A Windows XP style group box. A Macintosh style group box. A Plastique style group box.

See also

PySide.QtGui.QButtonGroup Group Box Example

class PySide.QtGui.QGroupBox([parent=None])
class PySide.QtGui.QGroupBox(title[, parent=None])
Parameters:

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

Constructs a group box with the given title and parent .

PySide.QtGui.QGroupBox.alignment()
Return type:PySide.QtCore.Qt.Alignment

This property holds the alignment of the group box title..

Most styles place the title at the top of the frame. The horizontal alignment of the title can be specified using single values from the following list:

  • Qt.AlignLeft aligns the title text with the left-hand side of the group box.
  • Qt.AlignRight aligns the title text with the right-hand side of the group box.
  • Qt.AlignHCenter aligns the title text with the horizontal center of the group box.

The default alignment is Qt.AlignLeft .

See also

Qt.Alignment

PySide.QtGui.QGroupBox.clicked([checked=false])
Parameters:checkedPySide.QtCore.bool
PySide.QtGui.QGroupBox.initStyleOption(option)
Parameters:optionPySide.QtGui.QStyleOptionGroupBox

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

PySide.QtGui.QGroupBox.isCheckable()
Return type:PySide.QtCore.bool

This property holds whether the group box has a checkbox in its title.

If this property is true, the group box displays its title using a checkbox in place of an ordinary label. If the checkbox is checked, the group box’s children are enabled; otherwise they are disabled and inaccessible.

By default, group boxes are not checkable.

If this property is enabled for a group box, it will also be initially checked to ensure that its contents are enabled.

See also

checked()

PySide.QtGui.QGroupBox.isChecked()
Return type:PySide.QtCore.bool

This property holds whether the group box is checked.

If the group box is checkable, it is displayed with a check box. If the check box is checked, the group box’s children are enabled; otherwise the children are disabled and are inaccessible to the user.

By default, checkable group boxes are also checked.

See also

checkable()

PySide.QtGui.QGroupBox.isFlat()
Return type:PySide.QtCore.bool

This property holds whether the group box is painted flat or has a frame.

A group box usually consists of a surrounding frame with a title at the top. If this property is enabled, only the top part of the frame is drawn in most styles; otherwise the whole frame is drawn.

By default, this property is disabled; i.e. group boxes are not flat unless explicitly specified.

Note

In some styles, flat and non-flat group boxes have similar representations and may not be as distinguishable as they are in other styles.

PySide.QtGui.QGroupBox.setAlignment(alignment)
Parameters:alignmentPySide.QtCore.int
PySide.QtGui.QGroupBox.setCheckable(checkable)
Parameters:checkablePySide.QtCore.bool

This property holds whether the group box has a checkbox in its title.

If this property is true, the group box displays its title using a checkbox in place of an ordinary label. If the checkbox is checked, the group box’s children are enabled; otherwise they are disabled and inaccessible.

By default, group boxes are not checkable.

If this property is enabled for a group box, it will also be initially checked to ensure that its contents are enabled.

See also

checked()

PySide.QtGui.QGroupBox.setChecked(checked)
Parameters:checkedPySide.QtCore.bool

This property holds whether the group box is checked.

If the group box is checkable, it is displayed with a check box. If the check box is checked, the group box’s children are enabled; otherwise the children are disabled and are inaccessible to the user.

By default, checkable group boxes are also checked.

See also

checkable()

PySide.QtGui.QGroupBox.setFlat(flat)
Parameters:flatPySide.QtCore.bool

This property holds whether the group box is painted flat or has a frame.

A group box usually consists of a surrounding frame with a title at the top. If this property is enabled, only the top part of the frame is drawn in most styles; otherwise the whole frame is drawn.

By default, this property is disabled; i.e. group boxes are not flat unless explicitly specified.

Note

In some styles, flat and non-flat group boxes have similar representations and may not be as distinguishable as they are in other styles.

PySide.QtGui.QGroupBox.setTitle(title)
Parameters:title – unicode

This property holds the group box title text.

The group box title text will have a keyboard shortcut if the title contains an ampersand (‘&’) followed by a letter.

g.setTitle("&User information")

In the example above, Alt+U moves the keyboard focus to the group box. See the QShortcut documentation for details (to display an actual ampersand, use ‘&&’).

There is no default title text.

PySide.QtGui.QGroupBox.title()
Return type:unicode

This property holds the group box title text.

The group box title text will have a keyboard shortcut if the title contains an ampersand (‘&’) followed by a letter.

g.setTitle("&User information")

In the example above, Alt+U moves the keyboard focus to the group box. See the QShortcut documentation for details (to display an actual ampersand, use ‘&&’).

There is no default title text.

PySide.QtGui.QGroupBox.toggled(arg__1)
Parameters:arg__1PySide.QtCore.bool