QButtonGroup Class Reference


The QButtonGroup widget organizes QButton widgets in a group. More...

#include <qbttngrp.h>

Inherits QGroupBox.

List of all member functions.

Public Members

Signals

Protected Slots


Detailed Description

The QButtonGroup widget organizes QButton widgets in a group.

A button group widget makes it easier to deal with groups of buttons. A button in a button group is associated with a unique identifer. The button group emits a clicked() signal with this identifier when the button is clicked.

An exclusive button group switches off all toggle buttons except the one that was clicked. A button group is by default non-exclusive, however, it automatically becomes an exclusive group when a QRadioButton is inserted.

There are two standard ways of using a button group:

  1. The button group is a normal parent widget for a number of buttons, i.e. the button group is the parent argument in the button contructor. The buttons are assigned identifiers 0, 1, 2 etc. in the order they are inserted. Since QButtonGroup inherits QGroupBox, it can display a frame and a title.
  2. The button group is an invisible widget and the contained buttons have some other parent widget. A button must then be manually inserted using the insert() function with an identifer.

See also: QButton, QPushButton, QCheckBox and QRadioButton.

Examples: drawdemo/drawdemo.cpp widgets/widgets.cpp


Member Function Documentation

QButtonGroup::QButtonGroup ( QWidget *parent=0, const char *name=0)

Constructs a button group with no title.

The parent and name arguments are passed to the QWidget constructor.

QButtonGroup::QButtonGroup ( const char *title, QWidget *parent=0, const char *name=0)

Constructs a button group with a title.

The parent and name arguments are passed to the QWidget constructor.

QButtonGroup::~QButtonGroup ()

Destroys the button group and its child widgets.

void QButtonGroup::buttonClicked () [protected slot]

For internal use only.

void QButtonGroup::buttonPressed () [protected slot]

For internal use only.

void QButtonGroup::buttonReleased () [protected slot]

For internal use only.

void QButtonGroup::clicked ( int id) [signal]

This signal is emitted when a button in the group is clicked. The id argument is the button's identifier.

QButton * QButtonGroup::find ( int id) const

Finds and returns a pointer to the button with the specified identifier id.

Returns null if the button was not found.

int QButtonGroup::insert ( QButton *button, int id=-1)

Inserts a button with the identifier id into the button group. Returns the button identifier.

The button is assigned the identifier id or an automatically generated identifier. It works as follows: If id >= 0, this identifier is assigned. If id == -1 (default), the identifier is equal to the number of buttons in the group. If id is any other negative integer, for instance -2, a unique identifier (negative integer <= -2) is generated.

Inserting several buttons with id = -1 assigns the identifers 0, 1, 2, etc.

This function calls setExclusive(TRUE) if button is a QRadioButton.

See also: find(), remove() and setExclusive().

bool QButtonGroup::isExclusive () const

Returns TRUE if the button group is exclusive, otherwise FALSE.

See also: setExclusive().

void QButtonGroup::pressed ( int id) [signal]

This signal is emitted when a button in the group is pressed. The id argument is the button's identifier.

void QButtonGroup::released ( int id) [signal]

This signal is emitted when a button in the group is released. The id argument is the button's identifier.

void QButtonGroup::remove ( QButton *button)

Removes a button from the button group.

See also: insert().

void QButtonGroup::setExclusive ( bool enable)

Sets the button group to be exclusive if enable is TRUE, or to be non-exclusive if enable is FALSE.

An exclusive button group switches off all other toggle buttons when one is switched on. This is ideal for groups of radio buttons A non-exclusive group allow many buttons to be swithed on at the same time.

The default setting is FALSE. A button group automatically becomes an exclusive group when a QRadioButton is inserted.

See also: isExclusive().


This file is part of the Qt toolkit, copyright © 1995-96 Troll Tech, all rights reserved.

It was generated from the following files:


Generated at 16:51, 1996/09/24 for Qt version 1.0 by the webmaster at Troll Tech