我在运行时创建TableViewColumns
,需要将role
传递给TableViewColumn
。
TableView {
model: myModel
onModelChanged: {
var roleList = myModel.customRoleNames
for ( var i = 0; i < roleList.length; ++i ) {
var role = roleList[ i ]
addColumn( /* my column component here */ )
}
}
}
Component {
id: columnComponent
TableViewColumn {
role: /* ??? */
}
}
如何在实例化我的组件时将role
提供给我的组件?
答案 0 :(得分:1)
好的,我已经知道了。这是解决方案:
SYNTAX 1.3.6.1.4.1.1466.115.121.1.15
当然,这适用于TableView {
id: myTableView
model: myModel
onModelChanged: {
var roleList = myModel.customRoleNames
for ( var i = 0; i < roleList.length; ++i ) {
var role = roleList[ i ]
addColumn( columnComponent.createObject ( myTableView, { "role": role } ) )
}
}
}
Component {
id: columnComponent
TableViewColumn { }
}
的所有属性,例如:
TableViewColumn