how to access properties in a delegate
-
lets say i have a tableview and i am using tableview column just like in the code.
TableView{ id:fav_table_view objectName: "favourite_table_view" width: 800 height: 250 model: fav_listModel property int updatedRow : -1 onUpdatedRowChanged:{ console.log("the delegate visibility is", label1.width) } TableViewColumn{ objectName: "ModuleName" role: "module_name" title: "Module Name" width: fav_table_view.width/3 delegate: moduleName } Component{ id:namedelegate Item { id: label1 objectName: "nameItem" anchors.verticalCenter: parent.verticalCenter Label { anchors.verticalCenter: parent.verticalCenter id:labname objectName: "registername" width:200 text: styleData.value } }
How do i get the width of the delegate element in the main tableview?
-
How about giving the width for TableViewColumn only. This will be used for that delegate.
-
@dheerendra in this example i have given width, what if i want to access the visibility or a property i have defined in the delegate?
-
"what if i want to access the visibility or a property i have defined in the delegate?"
There are multiple instances of your delegate, corresponding to the part of the model being displayed. Which instance do you want the property from? If it's a common property that is not specific to a single instance, then the same answer applies - factor it out to the table level and use it in the delegate. If it is a property specific to a delegate instance you are interested in, how do you specify which delegate? Does the data actually belong to the model?
What is it that you are trying to achieve?