【qml】Unable to assign QQuickTextInput to QString
问题现象
TableView {
itemDelegate: TextInput{
id: text
text: styleData.value // 该行报错:Unable to assign QQuickTextInput to QString
}
onAccepted: {
updateDb(styleData.row, styleData.column, text);
}
}
问题原因
TextInput的id为“text”,和TextInput的属性同名,在onAccepted函数调用时使用的是id。
解决方案
id: text 行改为:
id: otherName
【qml】Unable to assign QQuickTextInput to QString
问题现象
TableView {
itemDelegate: TextInput{
id: text
text: styleData.value // 该行报错:Unable to assign QQuickTextInput to QString
}
onAccepted: {
updateDb(styleData.row, styleData.column, text);
}
}
问题原因
TextInput的id为“text”,和TextInput的属性同名,在onAccepted函数调用时使用的是id。
解决方案
id: text 行改为:
id: otherName