CheckBox QML Type | Qt Quick Controls 2 5.9

Qt 5.9 | Qt Quick Controls 2 | QML Types | CheckBox QML Type

Qt 5.9.4 Reference Documentation

# CheckBox QML Type

Check button that can be toggled on or off. More...

Import Statement: | import QtQuick.Controls 2.2
Since: | Qt 5.7
Inherits: | AbstractButton

- List of all members, including inherited members

## Properties

- checkState : enumeration
- tristate : bool

## Detailed Description

CheckBox presents an option button that can be toggled on (checked) or off (unchecked). Check boxes are typically used to select one or more options from a set of options. For larger sets of options, such as those in a list, consider using CheckDelegate instead.

CheckBox inherits its API from AbstractButton. For instance, the state of the checkbox can be set with the checked property.

In addition to the checked and unchecked states, there is a third state: partially checked. The partially checked state can be enabled using the tristate property. This state indicates that the regular checked/unchecked state can not be determined; generally because of other states that affect the checkbox. This state is useful when several child nodes are selected in a treeview, for example.

      ColumnLayout {
          CheckBox {
              checked: true
              text: qsTr("First")
          }
          CheckBox {
              text: qsTr("Second")
          }
          CheckBox {
              checked: true
              text: qsTr("Third")
          }
      }

See also Customizing CheckBox and Button Controls.

## Property Documentation

checkState : enumeration

This property holds the check state of the checkbox.

Available states:

Constant | Description
--- | ---
`Qt.Unchecked` | The checkbox is unchecked.
`Qt.PartiallyChecked` | The checkbox is partially checked. This state is only used when tristate is enabled.
`Qt.Checked` | The checkbox is checked.

See also tristate and checked.

tristate : bool

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

In the animation below, the first checkbox is tri-state:

The default is `false`, i.e., the checkbox has only two states.