Qt Reference Documentation

QML CheckBox Element

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

Inherits Item

  • List of all members, including inherited members
  • Properties


    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

    read-onlychecked : bool

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

    read-onlypressed : bool

    If the button is pressed, its pressed property is true.

    See also clicked.

    read-onlytext : string

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

    Signal 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.