QML Switch UI : Color property



  • How can I change the color of the Switch UI in QML. How to I access the property ?



  • I'm not sure if you are talking about what I think but if you talk about the Switch from Qt quick controls here is an example :

        Switch {
            id: sw
            style: SwitchStyle {
                groove: Rectangle {
                        implicitWidth: 50
                        implicitHeight: 20
                        radius: 9
                        border.color: "black"
                        border.width: 1
                        color: sw.checked ? "blue" : "white"
                }
                handle: Rectangle{
                    implicitWidth: sw.width/2
                    implicitHeight: 20
                    radius: 9
                    border.color: "black"
                    border.width: 1
                }
            }
         }
    
    

    For more information : SwitchStyle


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.