Home · All Classes · Modules

QButtonGroup Class Reference
[QtGui module]

The QButtonGroup class provides a container to organize groups of button widgets. More...

Inherits QObject.

Methods

Qt Signals


Detailed Description

The QButtonGroup class provides a container to organize groups of button widgets.

QButtonGroup provides an abstract container into which button widgets can be placed. It does not provide a visual representation of this container (see QGroupBox for a container widget), but instead manages the states of each of the buttons in the group.

An exclusive button group switches off all checkable (toggle) buttons except the one that was clicked. By default, a button group is exclusive. The buttons in a button group are usually checkable QPushButton's, QCheckBoxes (normally for non-exclusive button groups), or QRadioButtons. If you create an exclusive button group, you should ensure that one of the buttons in the group is initially checked; otherwise, the group will initially be in a state where no buttons are checked.

A button is added to the group with addButton(). It can be removed from the group with removeButton(). If the group is exclusive, the currently checked button is available as checkedButton(). If a button is clicked the buttonClicked() signal is emitted. For a checkable button in an exclusive group this means that the button was checked. The list of buttons in the group is returned by buttons().

In addition, QButtonGroup can map between integers and buttons. You can assign an integer id to a button with setId(), and retrieve it with id(). The id of the currently checked button is available with checkedId(), and there is an overloaded signal buttonClicked() which emits the id of the button. The purpose of the mapping mechanism is to simplify the representation of enum values in a user interface.

See also QGroupBox, QPushButton, QCheckBox, and QRadioButton.


Method Documentation

QButtonGroup.__init__ (self, QObject parent = None)

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

Constructs a new, empty button group with the given parent.

See also addButton() and setExclusive().

QButtonGroup.addButton (self, QAbstractButton)

Adds the given button to the end of the group's internal list of buttons.

See also removeButton().

QButtonGroup.addButton (self, QAbstractButton, int id)

This is an overloaded member function, provided for convenience.

Adds the given button to the button group, with the given id.

See also removeButton() and buttons().

QAbstractButton QButtonGroup.button (self, int id)

Returns the button with the specified id, or 0 if no such button exists.

This function was introduced in Qt 4.1.

QAbstractButton-list QButtonGroup.buttons (self)

Returns the list of this groups's buttons. This may be empty.

See also addButton() and removeButton().

QAbstractButton QButtonGroup.checkedButton (self)

Returns the button group's checked button, or 0 if no buttons are checked.

See also buttonClicked().

int QButtonGroup.checkedId (self)

Returns the id of the checkedButton(), or -1 if no button is checked.

This function was introduced in Qt 4.1.

See also setId().

bool QButtonGroup.exclusive (self)

int QButtonGroup.id (self, QAbstractButton button)

Returns the id for the specified button, or -1 if no such button exists.

This function was introduced in Qt 4.1.

See also setId().

QButtonGroup.removeButton (self, QAbstractButton)

Removes the given button from the button group.

See also addButton() and buttons().

QButtonGroup.setExclusive (self, bool)

QButtonGroup.setId (self, QAbstractButton button, int id)

Sets the id for the specified button.

This function was introduced in Qt 4.1.

See also id().


Qt Signal Documentation

void buttonClicked (QAbstractButton *)

This signal is emitted when the given button is clicked. A button is clicked when it is first pressed and then released, when its shortcut key is typed, or programmatically when QAbstractButton.click() or QAbstractButton.animateClick() is called.

See also checkedButton() and QAbstractButton.clicked().

void buttonClicked (int)

This is an overloaded member function, provided for convenience.

This signal is emitted when a button with the given id is clicked.

See also checkedButton() and QAbstractButton.clicked().

void buttonPressed (QAbstractButton *)

This signal is emitted when the given button is pressed down.

This function was introduced in Qt 4.2.

See also QAbstractButton.pressed().

void buttonPressed (int)

This is an overloaded member function, provided for convenience.

This signal is emitted when a button with the given id is pressed down.

This function was introduced in Qt 4.2.

See also QAbstractButton.pressed().

void buttonReleased (QAbstractButton *)

This signal is emitted when the given button is released.

This function was introduced in Qt 4.2.

See also QAbstractButton.released().

void buttonReleased (int)

This is an overloaded member function, provided for convenience.

This signal is emitted when a button with the given id is released.

This function was introduced in Qt 4.2.

See also QAbstractButton.released().


PyQt 4.3.1 for X11Copyright © Riverbank Computing Ltd and Trolltech AS 2007Qt 4.3.0