Qt Reference Documentation

QML RadioButton Element

Provides a radio button with a line of text that the user can choose. More...

Inherits Item

  • List of all members, including inherited members
  • Properties

    Signals

    Detailed Description

    A radio button component consists of a radio button and a line of text. Only one item in a list may be selected at a time. Once an item is selected, it can be deselected only by selecting another item. Initial item selection may be set at the list creation. If not set, the list is shown without a selection.

    When a radio button has the focus, the radio button can be selected using the Qt.Key_Select, Qt.Key_Return, and Qt.Key_Enter hardware keys.

    Using a Radio Button

    The following code creates a row with three radio buttons in it. The platformExclusiveGroup property of all the radio buttons is 'group' which is a CheckableGroup. This enforces that only one of the radio buttons can be selected at a time. The radio button with the text '3' is checked.

     CheckableGroup { id: group }
     Row {
         id: row
         spacing: platformStyle.paddingMedium
         RadioButton {
             id: button1
             text: "1"
             platformExclusiveGroup: group
         }
         RadioButton {
             id: button2
             text: "2"
             platformExclusiveGroup: group
         }
         RadioButton {
             id: button3
             text: "3"
             platformExclusiveGroup: group
             checked: true
         }
     }

    The screenshot below shows the result of the code snippet.

    Property Documentation

    read-onlychecked : bool

    If a button is checked, checked is true. Otherwise it is false.

    See also Checkable.


    platformExclusiveGroup : QtObject

    The exclusive group that this radio button belongs to. In an exclusive group, only one of the radio buttons can be selected at a time.

    See also CheckableGroup.


    read-onlypressed : bool

    Indicates that the user is pressing this radio button.

    See also clicked().


    read-onlytext : string

    The text that is shown beside the radio button.


    Signal Documentation

    RadioButton::clicked ()

    This signal is emitted if the button is pressed and then released.