HomeHome

Classes - Annotated - Tree - Functions - Home - Structure Qte

QCheckBox Class Reference


The QCheckBox widget provides a check box with a text label. More...

#include <qcheckbox.h>

Inherits QButton.

List of all member functions.

Public Members

Important Inherited Members

Properties

TypeNameREADWRITEOptions
boolcheckedisCheckedsetChecked 
booltristateisTristatesetTristate 

Detailed Description

The QCheckBox widget provides a check box with a text label.

QCheckBox and QRadioButton are both option buttons. That is, they can be switched on (checked) or off (unchecked). The classes differ in how the choices for the user are restricted. Radio buttons define a "one of many" choice, while check-boxes provide "many of many" choices.

While it is technically possible to implement radio-behaviour with check boxes and vice versa, it's strongly recommended to stick with the well-known semantics. Otherwise your users would be pretty confused.

Use QButtonGroup to group check-buttons visually.

Whenver a check box is checked or cleared, it emits the signal toggled(). Connect to this signal if you want to trigger an action each time the box changes state. Otherwise, use isChecked() to query whether or not a particular check box is selected.

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 setting nor unsetting an option. If you need that third state, enable it with setTristate() and use state() to query the current toggle state. When a tristate box changes state, it emits the stateChanged() signal.

See also QButton, QRadioButton and Fowler: Check Box.

Examples: xform/xform.cpp i18n/main.cpp


Member Function Documentation

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

Constructs a check box with no text.

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

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

Constructs a check box with a text.

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

void QCheckBox::drawButton ( QPainter * paint ) [virtual protected]

Reimplemented for internal reasons; the API is not affected.

Reimplemented from QButton.

void QCheckBox::drawButtonLabel ( QPainter * p ) [virtual protected]

Reimplemented for internal reasons; the API is not affected.

Reimplemented from QButton.

bool QCheckBox::isChecked () const

Returns TRUE if the check box is checked, or FALSE if it is not checked.

See also setChecked().

Examples: xform/xform.cpp

bool QCheckBox::isTristate () const

Returns TRUE if the checkbox is a tristate checkbox. Otherwise returns FALSE.

See also setTristate().

void QCheckBox::resizeEvent ( QResizeEvent * ) [virtual protected]

Reimplemented for internal reasons; the API is not affected.

Reimplemented from QWidget.

void QCheckBox::setChecked ( bool check )

Checks the check box if check is TRUE, or unchecks it if check is FALSE.

See also isChecked().

void QCheckBox::setNoChange ()

Sets the checkbox into the "no change" state.

See also setTristate().

void QCheckBox::setTristate ( bool y=TRUE )

Makes the check box a tristate check box if y is TRUE. A tristate check box provides an additional state NoChange.

Use tristate check boxes whenever you need to give the user the option of neither setting nor unsetting an option. A typical example is the "Italic" check box in the font dialog of a word processor when the marked text is partially Italic and partially not.

See also isTristate(), setNoChange(), stateChanged() and state().

QSize QCheckBox::sizeHint () const [virtual]

Reimplemented for internal reasons; the API is not affected.

Reimplemented from QWidget.

QSizePolicy QCheckBox::sizePolicy () const [virtual]

Reimplemented for internal reasons; the API is not affected.

Reimplemented from QWidget.

void QCheckBox::updateMask () [virtual protected]

Reimplemented for internal reasons; the API is not affected.

Reimplemented from QWidget.


Search the documentation, FAQ, qt-interest archive and more (uses www.trolltech.com):


This file is part of the Qt toolkit, copyright © 1995-2005 Trolltech, all rights reserved.


Copyright © 2005 TrolltechTrademarks
Qt version 2.3.10