Home | All Classes | Main Classes | Annotated | Grouped Classes | Functions

QCheckBox Class Reference

The QCheckBox widget provides a checkbox with a text label. More...

#include <QCheckBox>

Inherits QAbstractButton.

Public Types

Writable Properties

Read-Only Properties

Public Functions

Public Slots

Signals

Static Public Members

Protected Functions


Detailed Description

The QCheckBox widget provides a checkbox with a text label.

A QCheckBox is an option button that can be switched on (checked) or off (unchecked). Checkboxes are typically used to represent features in an application that can be enabled or disabled without affecting others, but different types of behavior can be implemented.

A QButtonGroup can be used to group check buttons visually.

Whenever a checkbox is checked or cleared it emits the signal stateChanged(). Connect to this signal if you want to trigger an action each time the checkbox changes state. You can use isChecked() to query whether or not a checkbox is checked.

In addition to the usual checked and unchecked states, QCheckBox optionally provides a third state to indicate "no change". This is useful whenever you need to give the user the option of neither checking nor unchecking a checkbox. If you need this third state, enable it with setTristate(), and use state() to query the current toggle state.

Just like QPushButton, a checkbox can display text or a pixmap. The text can be set in the constructor or with setText(); the pixmap is set with setPixmap().

Important inherited functions: text(), setText(), text(), pixmap(), setPixmap(), accel(), setAccel(), isToggleButton(), setDown(), isDown(), isOn(), state(), autoRepeat(), isExclusiveToggle(), group(), setAutoRepeat(), toggle(), pressed(), released(), clicked(), toggled(), state(), and stateChanged().

Screenshot in Motif style Screenshot in Windows style

Fowler: Check Box

See also QButton and QRadioButton.


Member Type Documentation

enum QCheckBox::ToggleState

QCheckBox::Off 
QCheckBox::NoChange 
QCheckBox::On 

Property Documentation

autoMask : bool

This property holds whether the checkbox is automatically masked.

See also QWidget::setAutoMask().

tristate : bool

This property holds whether the checkbox is a tri-state checkbox.

The default is false; i.e. the checkbox has only two states.

Access functions:


Member Function Documentation

QCheckBox::QCheckBox ( QWidget * parent = 0 )

Constructs a checkbox with the given parent, but with no text.

The parent argument is passed on to the QAbstractButton constructor.

QCheckBox::QCheckBox ( const QString & text, QWidget * parent = 0 )

Constructs a checkbox with the given parent and text.

The parent argument is passed on to the QAbstractButton constructor.

void QCheckBox::setState ( ToggleState state )

Sets the check box's toggle state to state.

See also state() and ToggleState.

ToggleState QCheckBox::state () const

Returns the check box's toggle state.

See also setState() and ToggleState.

void QCheckBox::stateChanged ( int state )   [signal]

This signal is emitted whenever the check box's state changes, i.e. whenever the user checks or unchecks it.

state contains the check box's new ToggleState.


Copyright © 2004 Trolltech Trademarks
Qt 4.0.0-b1