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

TQCheckBox Class Reference

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

#include <tqcheckbox.h>

Inherits TQButton.

List of all member functions.

Public Members

Public Slots

Important Inherited Members

Properties


Detailed Description

The TQCheckBox widget provides a checkbox with a text label.

TQCheckBox and TQRadioButton 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, whereas checkboxes provide "many of many" choices.

A TQButtonGroup can be used to group check buttons visually.

Whenever a checkbox is checked or cleared it emits the signal toggled(). 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.

Warning: The toggled() signal can not be trusted for tristate checkboxes.

In addition to the usual checked and unchecked states, TQCheckBox 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. When a tristate checkbox changes state, it emits the stateChanged() signal.

Just like TQPushButton, 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().

See also TQButton, TQRadioButton, Fowler: Check Box, and Basic Widgets.


Member Function Documentation

TQCheckBox::TQCheckBox ( TQWidget * parent, const char * name = 0 )

Constructs a checkbox with no text.

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

TQCheckBox::TQCheckBox ( const TQString & text, TQWidget * parent, const char * name = 0 )

Constructs a checkbox with text text.

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

TQKeySequence TQButton::accel () const

Returns the accelerator associated with the button. See the "accel" property for details.

bool TQButton::autoRepeat () const

Returns TRUE if autoRepeat is enabled; otherwise returns FALSE. See the "autoRepeat" property for details.

void TQButton::clicked () [signal]

This signal is emitted when the button is activated (i.e. first pressed down and then released when the mouse cursor is inside the button), when the accelerator key is typed or when animateClick() is called. This signal is not emitted if you call setDown().

The TQButtonGroup::clicked() signal does the same job, if you want to connect several buttons to the same slot.

Warning: Don't launch a model dialog in response to this signal for a button that has autoRepeat turned on.

See also pressed(), released(), toggled(), autoRepeat, and down.

Examples: chart/setdataform.cpp, listbox/listbox.cpp, network/clientserver/client/client.cpp, progressbar/progressbar.cpp, richtext/richtext.cpp, t2/main.cpp, and t4/main.cpp.

TQButtonGroup * TQButton::group () const

Returns the group that this button belongs to.

If the button is not a member of any TQButtonGroup, this function returns 0.

See also TQButtonGroup.

bool TQCheckBox::isChecked () const

Returns TRUE if the checkbox is checked; otherwise returns FALSE. See the "checked" property for details.

bool TQButton::isDown () const

Returns TRUE if the button is pressed; otherwise returns FALSE. See the "down" property for details.

bool TQButton::isExclusiveToggle () const

Returns TRUE if the button is an exclusive toggle; otherwise returns FALSE. See the "exclusiveToggle" property for details.

bool TQButton::isOn () const

Returns TRUE if the button is toggled; otherwise returns FALSE. See the "on" property for details.

bool TQButton::isToggleButton () const

Returns TRUE if the button is a toggle button; otherwise returns FALSE. See the "toggleButton" property for details.

bool TQCheckBox::isTristate () const

Returns TRUE if the checkbox is a tri-state checkbox; otherwise returns FALSE. See the "tristate" property for details.

const TQPixmap * TQButton::pixmap () const

Returns the pixmap shown on the button. See the "pixmap" property for details.

void TQButton::pressed () [signal]

This signal is emitted when the button is pressed down.

See also released() and clicked().

Examples: network/httpd/httpd.cpp and popup/popup.cpp.

void TQButton::released () [signal]

This signal is emitted when the button is released.

See also pressed(), clicked(), and toggled().

void TQButton::setAccel ( const TQKeySequence & ) [virtual]

Sets the accelerator associated with the button. See the "accel" property for details.

void TQButton::setAutoRepeat ( bool ) [virtual]

Sets whether autoRepeat is enabled. See the "autoRepeat" property for details.

void TQCheckBox::setChecked ( bool check ) [slot]

Sets whether the checkbox is checked to check. See the "checked" property for details.

void TQButton::setDown ( bool ) [virtual]

Sets whether the button is pressed. See the "down" property for details.

void TQCheckBox::setNoChange ()

Sets the checkbox to the "no change" state.

See also tristate.

void TQButton::setPixmap ( const TQPixmap & ) [virtual]

Sets the pixmap shown on the button. See the "pixmap" property for details.

void TQButton::setText ( const TQString & ) [virtual]

Sets the text shown on the button. See the "text" property for details.

void TQCheckBox::setTristate ( bool y = TRUE )

Sets whether the checkbox is a tri-state checkbox to y. See the "tristate" property for details.

ToggleState TQButton::state () const

Returns the state of the toggle button. See the "toggleState" property for details.

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

This signal is emitted whenever a toggle button changes state. state is On if the button is on, NoChange if it is in the "no change" state or Off if the button is off.

This may be the result of a user action, toggle() slot activation, setState(), or because setOn() was called.

See also clicked() and TQButton::ToggleState.

TQString TQButton::text () const

Returns the text shown on the button. See the "text" property for details.

void TQButton::toggle () [slot]

Toggles the state of a toggle button.

See also on, setOn(), toggled(), and toggleButton.

void TQButton::toggled ( bool on ) [signal]

This signal is emitted whenever a toggle button changes status. on is TRUE if the button is on, or FALSE if the button is off.

This may be the result of a user action, toggle() slot activation, or because setOn() was called.

See also clicked().

Example: listbox/listbox.cpp.


Property Documentation

TQKeySequence accel

This property holds the accelerator associated with the button.

This property is 0 if there is no accelerator set. If you set this property to 0 then any current accelerator is removed.

Set this property's value with setAccel() and get this property's value with accel().

bool autoMask

This property holds whether the checkbox is automatically masked.

See also TQWidget::autoMask.

bool autoRepeat

This property holds whether autoRepeat is enabled.

If autoRepeat is enabled then the clicked() signal is emitted at regular intervals if the button is down. This property has no effect on toggle buttons. autoRepeat is off by default.

Set this property's value with setAutoRepeat() and get this property's value with autoRepeat().

bool checked

This property holds whether the checkbox is checked.

The default is unchecked, i.e. FALSE.

Set this property's value with setChecked() and get this property's value with isChecked().

TQPixmap pixmap

This property holds the pixmap shown on the button.

If the pixmap is monochrome (i.e. it is a TQBitmap or its depth is 1) and it does not have a mask, this property will set the pixmap to be its own mask. The purpose of this is to draw transparent bitmaps which are important for toggle buttons, for example.

pixmap() returns 0 if no pixmap was set.

Set this property's value with setPixmap() and get this property's value with pixmap().

TQString text

This property holds the text shown on the button.

This property will return a TQString::null if the button has no text. If the text has an ampersand (&) in it, then an accelerator is automatically created for it using the character that follows the '&' as the accelerator key. Any previous accelerator will be overwritten, or cleared if no accelerator is defined by the text.

There is no default text.

Set this property's value with setText() and get this property's value with text().

bool tristate

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

The default is two-state, i.e. tri-state is FALSE.

Set this property's value with setTristate() and get this property's value with isTristate().


This file is part of the TQt toolkit. Copyright © 1995-2007 Trolltech. All Rights Reserved.


Copyright © 2007 TrolltechTrademarks
TQt 3.3.8