Quantcast
Channel: QtWebEngine
Viewing all articles
Browse latest Browse all 13965

Noob question about Properties and Scopes

$
0
0
I’m totally new into the Qt and qml stuff and I just waste my all day trying to understand the property scopes without success. So I have a Table View with an Item delegate like this: TableView {        id: logView        model: logModel        TableViewColumn{             role:"idLog"         }        itemDelegate: Item {             id: logItem             property int idLog: -1          Rectangle {                 width:50                 height:20                 MouseArea{                     anchors.fill: parent                     onClicked: console.log( parent.parent.idLog) //always -1                     //onClicked: console.log( logItem.idLog)                 }           }             Component.onCompleted: {                 if (styleData.role === "idLog"){                    console.log(styleData.value) // 1 and 2                    idLog = styleData.value              }           }       } Component.onCompleted: {         logModel.append({"idLog":1})         logModel.append({"idLog":2})     } } And all I want is to save the id into the item prop so I can retrieve it after when I click the rect. I always get -1. Why is that?

Viewing all articles
Browse latest Browse all 13965

Trending Articles