QtBase
v6.3.1
|
The QCheckBox widget provides a checkbox with a text label. More...
#include <qcheckbox.h>
Signals | |
void | stateChanged (int) |
Signals inherited from QAbstractButton | |
void | pressed () |
void | released () |
void | clicked (bool checked=false) |
void | toggled (bool checked) |
Signals inherited from QWidget | |
void | windowTitleChanged (const QString &title) |
void | windowIconChanged (const QIcon &icon) |
void | windowIconTextChanged (const QString &iconText) |
void | customContextMenuRequested (const QPoint &pos) |
Signals inherited from QObject | |
void | destroyed (QObject *=nullptr) |
void | objectNameChanged (const QString &objectName, QPrivateSignal) |
Properties | |
bool | tristate |
whether the checkbox is a tri-state checkbox More... | |
Properties inherited from QAbstractButton | |
QString | text |
the text shown on the button More... | |
QIcon | icon |
the icon shown on the button More... | |
QSize | iconSize |
the icon size used for this button. More... | |
QKeySequence | shortcut |
the mnemonic associated with the button More... | |
bool | checkable |
whether the button is checkable More... | |
bool | checked |
whether the button is checked More... | |
bool | autoRepeat |
whether autoRepeat is enabled More... | |
bool | autoExclusive |
whether auto-exclusivity is enabled More... | |
int | autoRepeatDelay |
the initial delay of auto-repetition More... | |
int | autoRepeatInterval |
the interval of auto-repetition More... | |
bool | down |
whether the button is pressed down More... | |
Properties inherited from QWidget | |
bool | modal |
whether the widget is a modal widget More... | |
Qt::WindowModality | windowModality |
which windows are blocked by the modal widget More... | |
bool | enabled |
whether the widget is enabled More... | |
QRect | geometry |
the geometry of the widget relative to its parent and excluding the window frame More... | |
QRect | frameGeometry |
geometry of the widget relative to its parent including any window frame More... | |
QRect | normalGeometry |
the geometry of the widget as it will appear when shown as a normal (not maximized or full screen) top-level widget More... | |
int | x |
the x coordinate of the widget relative to its parent including any window frame More... | |
int | y |
the y coordinate of the widget relative to its parent and including any window frame More... | |
QPoint | pos |
the position of the widget within its parent widget More... | |
QSize | frameSize |
the size of the widget including any window frame More... | |
QSize | size |
the size of the widget excluding any window frame More... | |
int | width |
the width of the widget excluding any window frame More... | |
int | height |
the height of the widget excluding any window frame More... | |
QRect | rect |
the internal geometry of the widget excluding any window frame More... | |
QRect | childrenRect |
the bounding rectangle of the widget's children More... | |
QRegion | childrenRegion |
the combined region occupied by the widget's children More... | |
QSizePolicy | sizePolicy |
the default layout behavior of the widget More... | |
QSize | minimumSize |
the widget's minimum size More... | |
QSize | maximumSize |
the widget's maximum size in pixels More... | |
int | minimumWidth |
the widget's minimum width in pixels More... | |
int | minimumHeight |
the widget's minimum height in pixels More... | |
int | maximumWidth |
the widget's maximum width in pixels More... | |
int | maximumHeight |
the widget's maximum height in pixels More... | |
QSize | sizeIncrement |
the size increment of the widget More... | |
QSize | baseSize |
the base size of the widget More... | |
QPalette | palette |
the widget's palette More... | |
QFont | font |
the font currently set for the widget More... | |
QCursor | cursor |
the cursor shape for this widget More... | |
bool | mouseTracking |
whether mouse tracking is enabled for the widget More... | |
bool | tabletTracking |
whether tablet tracking is enabled for the widget More... | |
bool | isActiveWindow |
whether this widget's window is the active window More... | |
Qt::FocusPolicy | focusPolicy |
the way the widget accepts keyboard focus More... | |
bool | focus |
whether this widget (or its focus proxy) has the keyboard input focus More... | |
Qt::ContextMenuPolicy | contextMenuPolicy |
how the widget shows a context menu More... | |
bool | updatesEnabled |
whether updates are enabled More... | |
bool | visible |
whether the widget is visible More... | |
bool | minimized |
whether this widget is minimized (iconified) More... | |
bool | maximized |
whether this widget is maximized More... | |
bool | fullScreen |
whether the widget is shown in full screen mode More... | |
QSize | sizeHint |
the recommended size for the widget More... | |
QSize | minimumSizeHint |
the recommended minimum size for the widget More... | |
bool | acceptDrops |
whether drop events are enabled for this widget More... | |
QString | windowTitle |
the window title (caption) More... | |
QIcon | windowIcon |
the widget's icon More... | |
QString | windowIconText |
the text to be displayed on the icon of a minimized window More... | |
double | windowOpacity |
The level of opacity for the window. More... | |
bool | windowModified |
whether the document shown in the window has unsaved changes More... | |
QString | accessibleName |
the widget's name as seen by assistive technologies More... | |
QString | accessibleDescription |
the widget's description as seen by assistive technologies More... | |
Qt::LayoutDirection | layoutDirection |
the layout direction for this widget. More... | |
bool | autoFillBackground |
whether the widget background is filled automatically More... | |
QString | styleSheet |
the widget's style sheet More... | |
QLocale | locale |
the widget's locale More... | |
QString | windowFilePath |
the file path associated with a widget More... | |
Qt::InputMethodHints | inputMethodHints |
What input method specific hints the widget has. More... | |
Properties inherited from QObject | |
QString | objectName |
the name of this object More... | |
Friends | |
class | QAccessibleButton |
The QCheckBox widget provides a checkbox with a text label.
\inmodule QtWidgets
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. Different types of behavior can be implemented. For example, a QButtonGroup can be used to group check buttons logically, allowing exclusive checkboxes. However, QButtonGroup does not provide any visual representation.
The image below further illustrates the differences between exclusive and non-exclusive checkboxes.
\table \row
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 checkState() to query the current toggle state.
Just like QPushButton, a checkbox displays text, and optionally a small icon. The icon is set with setIcon(). The text can be set in the constructor or with setText(). A shortcut key can be specified by preceding the preferred character with an ampersand. For example:
In this example, the shortcut is {Alt+A}. See the \l{QShortcut::mnemonic} {QShortcut} documentation for details. To display an actual ampersand, use '&&'.
Important inherited functions: text(), setText(), text(), pixmap(), setPixmap(), accel(), setAccel(), isToggleButton(), setDown(), isDown(), isOn(), checkState(), autoRepeat(), isExclusiveToggle(), group(), setAutoRepeat(), toggle(), pressed(), released(), clicked(), toggled(), checkState(), and stateChanged().
Definition at line 54 of file qcheckbox.h.
Constructs a checkbox with the given parent, but with no text.
parent is passed on to the QAbstractButton constructor.
Definition at line 187 of file qcheckbox.cpp.
Constructs a checkbox with the given parent and text.
parent is passed on to the QAbstractButton constructor.
Definition at line 200 of file qcheckbox.cpp.
QCheckBox::~QCheckBox | ( | ) |
Destructor.
Definition at line 209 of file qcheckbox.cpp.
Qt::CheckState QCheckBox::checkState | ( | ) | const |
Returns the checkbox's check state. If you do not need tristate support, you can also use \l QAbstractButton::isChecked(), which returns a boolean.
Definition at line 232 of file qcheckbox.cpp.
|
overrideprotectedvirtual |
\reimp
Reimplemented from QAbstractButton.
Definition at line 353 of file qcheckbox.cpp.
|
overrideprotectedvirtual |
\reimp
Reimplemented from QAbstractButton.
Definition at line 381 of file qcheckbox.cpp.
\reimp
Reimplemented from QAbstractButton.
Definition at line 343 of file qcheckbox.cpp.
|
protectedvirtual |
Initializes option with the values from this QCheckBox. This method is useful for subclasses that require a QStyleOptionButton, but do not want to fill in all the information themselves.
Definition at line 161 of file qcheckbox.cpp.
bool QCheckBox::isTristate | ( | ) | const |
Definition at line 219 of file qcheckbox.cpp.
|
overridevirtual |
\reimp
Reimplemented from QWidget.
Definition at line 303 of file qcheckbox.cpp.
|
overrideprotectedvirtual |
\reimp
Reimplemented from QAbstractButton.
Definition at line 322 of file qcheckbox.cpp.
|
overrideprotectedvirtual |
\reimp
Reimplemented from QAbstractButton.
Definition at line 367 of file qcheckbox.cpp.
|
overrideprotectedvirtual |
\reimp
Implements QAbstractButton.
Definition at line 311 of file qcheckbox.cpp.
void QCheckBox::setCheckState | ( | Qt::CheckState | state | ) |
Sets the checkbox's check state to state. If you do not need tristate support, you can also use \l QAbstractButton::setChecked(), which takes a boolean.
Definition at line 247 of file qcheckbox.cpp.
Definition at line 213 of file qcheckbox.cpp.
|
overridevirtual |
\reimp
Reimplemented from QWidget.
Definition at line 282 of file qcheckbox.cpp.
|
signal |
This signal is emitted whenever the checkbox's state changes, i.e., whenever the user checks or unchecks it.
state contains the checkbox's new Qt::CheckState.
|
friend |
Definition at line 90 of file qcheckbox.h.
|
readwrite |
whether the checkbox is a tri-state checkbox
The default is false, i.e., the checkbox has only two states.
Definition at line 93 of file qcheckbox.h.