Customised RadioButton not working



  • Hi All,

    I am working with QtQuick 1.1

    I have a Radio as follows

    CRadio.qml

    import QtQuick 1.1
    
    Rectangle {
        id: sideButton
        property RadioGroup radioGroup
        property string text: 'Button'
        radius:20
        border.color: "black"
        border.width: 2
        property bool checked: false
    
        color:  radioGroup.selected === sideButton ? '#4FB549' :
                                                     (sideButtonMouseArea.containsMouse ? '#DDDDDD' : '#F4F4F4')
    
        onCheckedChanged:
        {
            console.log("onCheckedChanged");
            sideButton.radioGroup.selected === sideButton
        }
        MouseArea {
            id: sideButtonMouseArea
            anchors.fill: parent
            hoverEnabled: true
            onClicked: sideButton.radioGroup.selected = sideButton
    
        }
    }
    

    and

    RadioGroup.qml

    import QtQuick 1.1
    
    QtObject {
        id:root
        property Item selected : null
    }
    

    and in main.qml when i am calling

     RadioGroup {
            id: radioGroup1
        }
    
        CRadio
        {
            x:100
            y:220
            width:25
            checked:true
            radioGroup: radioGroup1
            height: 25
    
        }
    

    When UI is loaded i can click on the MouseArea, It is working fine on Loading.
    I am getting following error.
    qrc:/CRadio.qml:18: TypeError: Result of expression 'sideButton.radioGroup' [null] is not an object.

    What would will be problem ?

    Thanks in Advance.
    Regards,
    Basha.


Log in to reply
 

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