Recover id in variable



  • Buttons.qml

    Rectangle {
        width:60
        height: 80
       
        MouseArea{
            anchors.fill:parent
            onClicked: {
                    
                 loader.source="nextFile.qml"
                /* 
    I would like to retrieve here the id (in a variable) of my button which is defined in the main.qml */
    
            }
    
    

    main.qml

    Buttons{
        id: id1
         color:"red"
         x:150
         y:150
    }
    Buttons{
        id: id2
         color:"blue"
         x:200
         y:200
    }
    

    I would like to retrieve the id in a variable in onCliked {} but the id is in the main.qml and not in the Buttons.qml

    thanks you



  • @Titi01 Id's are special, they don't work like other properties. You have to explain what you want to achieve. Also you can't use id's declared in your main.qml in Buttons.qml.


Log in to reply
 

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