|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.trolltech.qt.internal.QSignalEmitterInternal
com.trolltech.qt.QSignalEmitter
com.trolltech.qt.QtJambiObject
com.trolltech.qt.core.QObject
com.trolltech.qt.gui.QWidget
com.trolltech.qt.gui.QAbstractButton
com.trolltech.qt.gui.QCheckBox
public class QCheckBox
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 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:
QCheckBox checkbox = new QCheckBox("C&ase sensitive", this);In this example the shortcut is Alt+A. See the
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()
.
![]() | A checkbox shown in the Macintosh widget style. |
![]() | A checkbox shown in the Windows XP widget style. |
![]() | A checkbox shown in the Plastique widget style. |
QAbstractButton
, QRadioButton
, and GUI Design Handbook: Check Box.
Nested Class Summary |
---|
Nested classes/interfaces inherited from class com.trolltech.qt.gui.QWidget |
---|
QWidget.RenderFlag, QWidget.RenderFlags |
Nested classes/interfaces inherited from class com.trolltech.qt.QSignalEmitter |
---|
QSignalEmitter.AbstractSignal, QSignalEmitter.Signal0, QSignalEmitter.Signal1, QSignalEmitter.Signal2, QSignalEmitter.Signal3, QSignalEmitter.Signal4, QSignalEmitter.Signal5, QSignalEmitter.Signal6, QSignalEmitter.Signal7, QSignalEmitter.Signal8, QSignalEmitter.Signal9 |
Nested classes/interfaces inherited from class com.trolltech.qt.internal.QSignalEmitterInternal |
---|
com.trolltech.qt.internal.QSignalEmitterInternal.AbstractSignalInternal |
Field Summary | |
---|---|
QSignalEmitter.Signal1 |
stateChanged
This signal takes 1 generic argument(s). |
Fields inherited from class com.trolltech.qt.gui.QAbstractButton |
---|
clicked, pressed, released, toggled |
Fields inherited from class com.trolltech.qt.gui.QWidget |
---|
customContextMenuRequested |
Fields inherited from class com.trolltech.qt.internal.QSignalEmitterInternal |
---|
currentSender |
Constructor Summary | |
---|---|
QCheckBox()
Constructs a checkbox with the given parent, but with no text. |
|
QCheckBox(QWidget parent)
Constructs a checkbox with the given parent, but with no text. |
|
QCheckBox(java.lang.String text)
Constructs a checkbox with the given parent and text. |
|
QCheckBox(java.lang.String text,
QWidget parent)
Constructs a checkbox with the given parent and text. |
Method Summary | |
---|---|
Qt.CheckState |
checkState()
Returns the check box's check state. |
protected void |
initStyleOption(QStyleOptionButton option)
Initialize option with the values from this QCheckBox. |
boolean |
isTristate()
This property holds whether the checkbox is a tri-state checkbox. |
void |
setCheckState(Qt.CheckState state)
Sets the check box's check state to state. |
void |
setTristate()
This property holds whether the checkbox is a tri-state checkbox. |
void |
setTristate(boolean y)
This property holds whether the checkbox is a tri-state checkbox. |
Methods inherited from class com.trolltech.qt.gui.QAbstractButton |
---|
animateClick, animateClick, autoExclusive, autoRepeat, autoRepeatDelay, autoRepeatInterval, checkStateSet, click, group, hitButton, icon, iconSize, isCheckable, isChecked, isDown, nextCheckState, setAutoExclusive, setAutoRepeat, setAutoRepeatDelay, setAutoRepeatInterval, setCheckable, setChecked, setDown, setIcon, setIconSize, setShortcut, setShortcut, setShortcut, setText, shortcut, text, toggle |
Methods inherited from class com.trolltech.qt.core.QObject |
---|
childEvent, children, connectSlotsByName, customEvent, disposeLater, dumpObjectInfo, dumpObjectTree, dynamicPropertyNames, event, eventFilter, findChild, findChild, findChild, findChildren, findChildren, findChildren, findChildren, indexOfProperty, installEventFilter, isWidgetType, killTimer, moveToThread, objectName, parent, properties, property, removeEventFilter, setObjectName, setParent, setProperty, startTimer, timerEvent, toString, userProperty |
Methods inherited from class com.trolltech.qt.QtJambiObject |
---|
dispose, disposed, equals, finalize, reassignNativeResources, tr, tr, tr |
Methods inherited from class com.trolltech.qt.QSignalEmitter |
---|
blockSignals, disconnect, disconnect, signalsBlocked, signalSender, thread |
Methods inherited from class com.trolltech.qt.internal.QSignalEmitterInternal |
---|
__qt_signalInitialization |
Methods inherited from class java.lang.Object |
---|
clone, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Methods inherited from interface com.trolltech.qt.QtJambiInterface |
---|
disableGarbageCollection, nativeId, nativePointer, reenableGarbageCollection, setJavaOwnership |
Field Detail |
---|
public final QSignalEmitter.Signal1 stateChanged
This signal takes 1 generic argument(s). We list their type and the name they go by in the description of this signal. <java.lang.Integer(named: state)>:
This signal is emitted whenever the check box's state changes, i. . whenever the user checks or unchecks it.
state contains the check box's new Qt::CheckState
.
Constructor Detail |
---|
public QCheckBox()
The parent argument is passed on to the QAbstractButton
constructor.
public QCheckBox(QWidget parent)
The parent argument is passed on to the QAbstractButton
constructor.
public QCheckBox(java.lang.String text)
The parent argument is passed on to the QAbstractButton
constructor.
public QCheckBox(java.lang.String text, QWidget parent)
The parent argument is passed on to the QAbstractButton
constructor.
Method Detail |
---|
public final Qt.CheckState checkState()
QAbstractButton::isChecked()
which returns a boolean. setCheckState()
, and Qt::CheckState
.
public final boolean isTristate()
public final void setCheckState(Qt.CheckState state)
QAbstractButton::setChecked()
which takes a boolean. checkState()
, and Qt::CheckState
.
public final void setTristate()
public final void setTristate(boolean y)
protected final void initStyleOption(QStyleOptionButton option)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |