QCheckBox(3qt)

πŸ“¦ version 3.3.8b, in fedora 43, fedora 44

okay bestie, welcome to QCheckBox(3qt) β€” the manual page that's about to make checkboxes make sense πŸ’…βœ¨

πŸ’– NAME πŸ’–

QCheckBox β€” checkbox with a text label. That's the whole vibe. No cap. βœ…

✨ SYNOPSIS ✨

#include <qcheckbox.h>

Inherits QButton.

Public Members

QCheckBox ( QWidget * parent, const char * name = 0 )
QCheckBox ( const QString & text, QWidget * parent, const char * name =
     0 )
bool isChecked () const
void setNoChange ()
void setTristate ( bool y = TRUE )
bool isTristate () const

Public Slots

void setChecked ( bool check )

Important Inherited Members

QString text () const
virtual void setText ( const QString & )
const QPixmap * pixmap () const
virtual void setPixmap ( const QPixmap & )
QKeySequence accel () const
virtual void setAccel ( const QKeySequence & )
bool isToggleButton () const
virtual void setDown ( bool )
bool isDown () const
bool isOn () const
ToggleState state () const
bool autoRepeat () const
virtual void setAutoRepeat ( bool )
bool isExclusiveToggle () const
QButtonGroup * group () const
void toggle ()
void pressed ()
void released ()
void clicked ()
void toggled ( bool on )
void stateChanged ( int state )

Properties

bool autoMask - whether the checkbox is automatically masked  (read
    only)
bool checked - whether the checkbox is checked
bool tristate - whether the checkbox is a tri-state checkbox

🌈 DESCRIPTION 🌈

QCheckBox is literally the widget that gives you a checkbox with a text label. Iconic. πŸ‘‘

QCheckBox and QRadioButton are both option buttons, bestie. That means they can be switched on (checked) or off (unchecked). The way they differ is how they restrict your choices: radio buttons are giving "one of many" energy, while checkboxes are all about "many of many" choices. So radio = pick one, checkbox = pick as many as you want. Periodt. πŸ’…

A QButtonGroup can be used to group check buttons visually.

Whenever a checkbox is checked or cleared, it emits the toggled() signal. Connect to this signal if you want to trigger an action every 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. Not me being dramatic, that's literally what the docs say. 😭

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. When a tristate checkbox changes state, it emits the stateChanged() signal.

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().

[Image Omitted]

[Image Omitted]

See also QButton, QRadioButton, Fowler: Check Box, and Basic Widgets.

🧠 MEMBER FUNCTION DOCUMENTATION 🧠

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

Constructs a checkbox 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 checkbox with text text.

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

QKeySequence QButton::accel () const

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

bool QButton::autoRepeat () const

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

void QButton::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 QButtonGroup::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. (Yes, it says "model dialog", not "modal". We're keeping it 100% accurate, bestie. 😭)

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

Examples: (the original leaves this blank, so... no code here, just vibes 🫢)

QButtonGroup * QButton::group () const

Returns the group that this button belongs to.

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

See also QButtonGroup.

bool QCheckBox::isChecked () const

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

bool QButton::isDown () const

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

bool QButton::isExclusiveToggle () const

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

bool QButton::isOn () const

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

bool QButton::isToggleButton () const

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

bool QCheckBox::isTristate () const

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

const QPixmap * QButton::pixmap () const

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

void QButton::pressed () [signal]

This signal is emitted when the button is pressed down.

See also released() and clicked().

Examples: (again, blank in the original β€” not a drill 😭)

void QButton::released () [signal]

This signal is emitted when the button is released.

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

void QButton::setAccel ( const QKeySequence & ) [virtual]

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

void QButton::setAutoRepeat ( bool ) [virtual]

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

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

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

void QButton::setDown ( bool ) [virtual]

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

void QCheckBox::setNoChange ()

Sets the checkbox to the "no change" state.

See also tristate.

void QButton::setPixmap ( const QPixmap & ) [virtual]

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

void QButton::setText ( const QString & ) [virtual]

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

void QCheckBox::setTristate ( bool y = TRUE )

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

ToggleState QButton::state () const

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

void QButton::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 QButton::ToggleState.

QString QButton::text () const

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

void QButton::toggle () [slot]

Toggles the state of a toggle button.

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

void QButton::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 πŸŽ€

QKeySequence 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 QWidget::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().

QPixmap pixmap

This property holds the pixmap shown on the button.

If the pixmap is monochrome (i.e. it is a QBitmap 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().

QString text

This property holds the text shown on the button.

This property will return a QString::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().

πŸ‘€ SEE ALSO πŸ‘€

Copyright 1992-2007 Trolltech ASA, http://www.trolltech.com. See the license file included in the distribution for a complete license statement.

✍️ AUTHOR ✍️

Generated automatically from the source code.

πŸ› BUGS πŸ›

Okay bestie, listen up, because if you find a bug in Qt we are NOT just gonna sit there and suffer in silence πŸ’€

If you find a bug in Qt, please report it like the instructions say at http://doc.trolltech.com/bughowto.html. Good bug reports literally help us help you. Thank you 🫢 (no seriously, the good ones are giving main character energy).

The definitive Qt documentation is provided in HTML format β€” it lives at $QTDIR/doc/html and you can read it using Qt Assistant or with a web browser. This man page is just here as a convenience for those users who prefer man pages, even though this format is not officially supported by Trolltech. So like… enjoy the vibe, but know that the HTML is the real one, iykyk ✨

If you find errors in this manual page, please report them to qt-bugs@trolltech.com. Please include the name of the manual page (qcheckbox.3qt) and the Qt version (3.3.8). Yes, both. Every time. That's the assignment, periodt πŸ’…


And that's a wrap on our little checkbox journey, bestie πŸŽ€ This absolute icon of a page was brought to you by Trolltech AS, dated 2 February 2007, filed under QCheckBox(3qt) β€” go forth and toggle responsibly, you're gonna slay πŸŒˆπŸ’–

πŸ“¦ where this page comes from