I have custom headerDelegate
inside TableView
. I need to access properties of TableViewColumn
such as resizable
property inside headerDelegate
.
Is there any way to access this property inside headerDelegate
?
Is it possible to access user defined properties in TableViewColumn
inside headerDelegate
?
For example can I create a user defined property called enableSorting
inside TableViewColumn
and access it inside headerDelegate
in order to hide or show sortingIndicator
?
UPDATE
TableView{
TableViewColumn{
property bool sortingEnabled: false
resizable: false
}
headerDelegate: Rectangle {
color: styleData.resizable?"red":"blue"
border.color:styleData.sortingEnabled?"red":"blue"
}
}
Here styleData.resizable
& styleData.sortingEnabled
are imaginary. I would like to get something like that.
From the documentation of TableView
, to access a column we can use
getColumn(index)
method
TableView{
TableViewColumn{
property bool sortingEnabled: false
resizable: false
}
headerDelegate: Rectangle {
color: getColumn(styleData.column).resizable?"red":"blue"
border.color:getColumn(styleData.column).sortingEnabled?"red":"blue"
}
}
What you want is to set the TableView id property. You will be able to access it from the entire file scope in all the way you want.
TableView{
id: myTableView
headerDelegate: Rectangle {
color: myTableView.whatever // Change whatever by any property of myTableView
}
}
Important note : Setting the delegate id and accessing the other way around will not work because it is not instanciated right at the reading of the qml interpreter, plus it probably would target several instances of delegate items.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.