How to change color for inactive status of StatusIndicator?



  • Hi,
    I am completely new to QML.

    I would like to change the color for the inactive status of a StatusIndicator to red:

    import QtQuick 2.2
    import QtQuick.Extras 1.4
    
        StatusIndicator {
            anchors.centerIn: parent
            color: "green" //Status active
          //color2: "red" //Status inactive
        }
    

    How can I do this?
    Thank you very much :-)



  • I think you'll have to write a Style to do that. You can probably just take the existing Style from the source and tweak it. Look for StatusIndicatorStyle.qml in your installation.



  • StatusIndicator {
            id: statusI
            active: true
            property bool rlyActive
               anchors.centerIn: parent
               color: rlyActive ? "green" : "red" //Status active
             //color2: "red" //Status inactive
               MouseArea {
                   anchors.fill: parent
                   onClicked: statusI.rlyActive = !statusI.rlyActive
               }
           }
    


  • Thank you very much for this nice solution :-)


Log in to reply
 

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