Qt World Summit: Submit your Presentation

RadioButton in qml

  • Hi,

    I am trying to create a RadioButton in qml as shown below:

    import QtQuick 2.12
    import QtQuick.Templates 2.12 as T
    import QtQuick.Controls 2.12
    import QtQuick.Controls.impl 2.12
    import QtQuick.Layouts 1.14
    import QtQuick.Controls.Styles 1.4
        RadioButton {
            id: r1
            checked: true
            text: qsTr("Option one")
        RadioButton {
            id: r2
            text: qsTr("Option two")
            anchors.top: r1.bottom
        RadioButton {
            id: r3
            text: qsTr("Option three")
            anchors.top: r2.bottom

    In this i am trying to change the background color of radio button can anyone suggest how to do that?

  • @QtQmlLearner the Qt documentation has a section on customising controls, including RadioButton. The general idea is to create your own custom derived type and use that in place of the built-in type.


  • @Bob64 Thank you so much for the link.

    I just want to know what is the difference between RadioButton and RadioDelegate.
    If you have any idea can you suggest??

  • RadioButton is similar to RadioDelegate, except that it is typically not used in views (Listview, Gridview), but rather when there are only a few options, and often with the requirement that each button is uniquely identifiable.

Log in to reply