在QML 5中工作,我希望根据列号对表内容(列)进行不同的格式化。例如,col 1保存一个字符串,col 2保存一个复选标记,col 3保存一个图像。等。
我希望在我的delegatechooser中使用列号,但它失败了(从不匹配roleValue)。如果我打印模型。列,它会显示列号,
如何在选择器中使用列号?
DelegateChooser {
id: chooser
role: "model.column"
DelegateChoice { roleValue: "0"; ItemDelegate { ... } }
DelegateChoice { roleValue: "1"; SwitchDelegate { ... } }
DelegateChoice { roleValue: "2"; SwipeDelegate { ... } }
}
DelegateChooser
的role
属性不是您需要的。
需要DelegateChoice
的column
性质:
DelegateChooser {
DelegateChoice { column: 0; ItemDelegate { ... } }
DelegateChoice { column: 1; SwitchDelegate { ... } }
DelegateChoice { column: 2; SwipeDelegate { ... } }
}