我在 QML 中有一个代码片段,它应该在 screen.text 中查找正则表达式“Calling”,如果没有找到,那么它才会更改 screen.text。不幸的是,QML/QString文档中的文档不清楚.
Button{
id: call
anchors.top: seven.bottom
anchors.left: seven.left
text: "Call"
width: 40
onClicked:{
if(screen.text.toString().startsWith("Calling" , false))
return;
else
screen.text = "Calling " + screen.text
}
}
我得到的错误是:
file:///home/arnab/workspace/desktop/examples/cellphone.qml:127: TypeError: 表达式'screen.text.toString().startsWith' [undefined] 的结果不是函数。