Qt Quick Components

CheckBox

A check box component has an image and a label and can be clicked by the user. More...

  • List of all members, including inherited members
  • Properties

    Signals

    Detailed Description

    A check box is an 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.

    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 application shows the signal and the state ('checked' or 'unchecked') of the check box.

             CheckBox {
                 id: chkCheckBox
                 text: "Check box text"
                 anchors.left: parent.left
                 anchors.right: parent.right
    
                 onClicked: {
                     txtLog.text = txtLog.text + "The 'clicked' signal: "
                     if (checked) {
                         txtLog.text = txtLog.text + "The check box is checked. <br>"
                     } else {
                         txtLog.text = txtLog.text + "The check box is unchecked. <br>"
                     }
                 }
             }

    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. The property is false by default.


    pressed : bool

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

    See also clicked.


    text : string

    Symbian:

    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.

    The signal handler, onClicked(), can bind to state changes or other actions.