最新消息: USBMI致力于为网友们分享Windows、安卓、IOS等主流手机系统相关的资讯以及评测、同时提供相关教程、应用、软件下载等服务。

【qml】Unable to assign QQuickTextInput to QString

互联网 admin 6浏览 0评论

【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

发布评论

评论列表 (0)

  1. 暂无评论