Qt Reference Documentation

QML CheckBox Element

Provides a component with an image and a label that the user can click. More...

This element was introduced in Qt Quick Components 1.0.


Signal Handlers

Detailed Description

A check box is a component that can be switched on (checked) or off (unchecked). Check boxes 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. When a check box is checked or unchecked it sends a clicked signal for the application to handle.

When a check box has the focus, its state can be toggled using the Qt.Key_Select, Qt.Key_Return, and Qt.Key_Enter hardware keys that send the clicked signal.

Checking and Unchecking a Check Box

In this example the user can check and uncheck a check box. In the code snippet below the check box is defined. When the user clicks the check box, the text label changes according to the state ('checked' or 'unchecked') of the check box.

 CheckBox {
     id: checkBox
     text: "Check box text"
 Text {
     text: checkBox.checked ? "Checked" : "Unchecked"
     font.pixelSize: platformStyle.fontSizeMedium
     font.family: platformStyle.fontFamilyRegular
     color: platformStyle.colorNormalLight

The screenshot below illustrates the case where the user has checked the check box.

Property Documentation

checked : bool

If the button is checked, its checked property is true; otherwise false. The property is false by default.

platformInverted : bool


If platformInverted is true, the component is visualized with the inverted style. For more information, see Using Inverted Style with Symbian Components. By default platformInverted is false.

This property group was introduced in Qt Quick Components 1.1.

pressed : bool

If the button is pressed, its pressed property is true; otherwise false.

See also clicked.

text : string

The text is shown beside the check box. By default text is an empty string.

Signal Handler Documentation

CheckBox::clicked ()

The signal is emitted when the button is pressed and then released.

You can bind the signal handler, onClicked, to state changes or other actions.