Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## com.trolltech.qt.gui
Class QCheckBox

    java.lang.Object
      com.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

All Implemented Interfaces:
  QPaintDeviceInterface, QtJambiInterface

    public class QCheckBox

extends QAbstractButton

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.

See also:
  `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.gui.QWidget
`acceptDrops, accessibleDescription, accessibleName, actionEvent, actions, activateWindow, addAction, addActions, adjustSize, autoFillBackground, backgroundRole, baseSize, changeEvent, childAt, childAt, childrenRect, childrenRegion, clearFocus, clearMask, close, closeEvent, contentsRect, contextMenuEvent, contextMenuPolicy, cursor, depth, destroy, destroy, destroy, dragEnterEvent, dragLeaveEvent, dragMoveEvent, dropEvent, effectiveWinId, ensurePolished, enterEvent, focusInEvent, focusNextChild, focusNextPrevChild, focusOutEvent, focusPolicy, focusPreviousChild, focusProxy, focusWidget, font, fontInfo, fontMetrics, foregroundRole, frameGeometry, frameSize, geometry, getContentsMargins, grabKeyboard, grabMouse, grabMouse, grabShortcut, grabShortcut, hasFocus, hasMouseTracking, height, heightForWidth, heightMM, hide, hideEvent, inputContext, inputMethodEvent, inputMethodQuery, insertAction, insertActions, isActiveWindow, isAncestorOf, isEnabled, isEnabledTo, isFullScreen, isHidden, isMaximized, isMinimized, isModal, isVisible, isVisibleTo, isWindow, isWindowModified, keyboardGrabber, keyPressEvent, keyReleaseEvent, languageChange, layout, layoutDirection, leaveEvent, locale, logicalDpiX, logicalDpiY, lower, mapFrom, mapFromGlobal, mapFromParent, mapTo, mapToGlobal, mapToParent, mask, maximumHeight, maximumSize, maximumWidth, metric, minimumHeight, minimumSize, minimumSizeHint, minimumWidth, mouseDoubleClickEvent, mouseGrabber, mouseMoveEvent, mousePressEvent, mouseReleaseEvent, move, move, moveEvent, nativeParentWidget, nextInFocusChain, normalGeometry, numColors, overrideWindowFlags, overrideWindowFlags, paintEngine, paintEvent, paintingActive, palette, parentWidget, physicalDpiX, physicalDpiY, pos, raise, rect, releaseKeyboard, releaseMouse, releaseShortcut, removeAction, render, render, render, render, render, render, render, render, render, repaint, repaint, repaint, repaint, resetInputContext, resize, resize, resizeEvent, restoreGeometry, saveGeometry, scroll, scroll, setAcceptDrops, setAccessibleDescription, setAccessibleName, setAttribute, setAttribute, setAutoFillBackground, setBackgroundRole, setBaseSize, setBaseSize, setContentsMargins, setContentsMargins, setContextMenuPolicy, setCursor, setDisabled, setEnabled, setFixedHeight, setFixedSize, setFixedSize, setFixedWidth, setFocus, setFocus, setFocusPolicy, setFocusProxy, setFont, setForegroundRole, setGeometry, setGeometry, setHidden, setInputContext, setLayout, setLayoutDirection, setLocale, setMask, setMask, setMaximumHeight, setMaximumSize, setMaximumSize, setMaximumWidth, setMinimumHeight, setMinimumSize, setMinimumSize, setMinimumWidth, setMouseTracking, setPalette, setParent, setParent, setParent, setShortcutAutoRepeat, setShortcutAutoRepeat, setShortcutEnabled, setShortcutEnabled, setSizeIncrement, setSizeIncrement, setSizePolicy, setSizePolicy, setStatusTip, setStyle, setStyleSheet, setTabOrder, setToolTip, setUpdatesEnabled, setVisible, setWhatsThis, setWindowFilePath, setWindowFlags, setWindowFlags, setWindowIcon, setWindowIconText, setWindowModality, setWindowModified, setWindowOpacity, setWindowRole, setWindowState, setWindowState, setWindowTitle, show, showEvent, showFullScreen, showMaximized, showMinimized, showNormal, size, sizeHint, sizeIncrement, sizePolicy, stackUnder, statusTip, style, styleSheet, tabletEvent, testAttribute, toolTip, underMouse, unsetCursor, unsetLayoutDirection, unsetLocale, update, update, update, update, updateGeometry, updateMicroFocus, updatesEnabled, visibleRegion, whatsThis, wheelEvent, width, widthMM, window, windowFilePath, windowFlags, windowIcon, windowIconText, windowModality, windowOpacity, windowRole, windowState, windowTitle, windowType, winId, x, y`

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

### stateChanged

    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

### QCheckBox

    public QCheckBox()

  Constructs a checkbox with the given `parent`, but with no text.

  The `parent` argument is passed on to the `QAbstractButton` constructor.

### QCheckBox

    public QCheckBox(QWidget parent)

  Constructs a checkbox with the given `parent`, but with no text.

  The `parent` argument is passed on to the `QAbstractButton` constructor.

### QCheckBox

    public QCheckBox(java.lang.String text)

  Constructs a checkbox with the given `parent` and `text`.

  The `parent` argument is passed on to the `QAbstractButton` constructor.

### QCheckBox

    public QCheckBox(java.lang.String text,
                     QWidget parent)

  Constructs a checkbox with the given `parent` and `text`.

  The `parent` argument is passed on to the `QAbstractButton` constructor.

Method Detail

### checkState

    public final Qt.CheckState checkState()

  Returns the check box's check state. If you do not need tristate support, you can also use `QAbstractButton::isChecked()` which returns a boolean.

See also:
  `setCheckState()`, and `Qt::CheckState` .

### isTristate

    public final boolean isTristate()

  This property holds whether the checkbox is a tri-state checkbox. The default is false; i.e. the checkbox has only two states.

### setCheckState

    public final void setCheckState(Qt.CheckState state)

  Sets the check box's check state to `state`. If you do not need tristate support, you can also use `QAbstractButton::setChecked()` which takes a boolean.

See also:
  `checkState()`, and `Qt::CheckState` .

### setTristate

    public final void setTristate()

  This property holds whether the checkbox is a tri-state checkbox. The default is false; i.e. the checkbox has only two states.

### setTristate

    public final void setTristate(boolean y)

  This property holds whether the checkbox is a tri-state checkbox. The default is false; i.e. the checkbox has only two states.

### initStyleOption

    protected final void initStyleOption(QStyleOptionButton option)

  Initialize `option` with the values from this QCheckBox. This method is useful for subclasses when they need a QStyleOptionButton, but don't want to fill in all the information themselves.

Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD