我使用C++函数(来自库,我没有看到实现)设置qml属性,在按钮上使用此函数属性 后按预期更改(我从C++代码设置的值),但在文本上设置“我的名字是:”没有价值。我的问题是,如何在QML javascript函数中加入两个字符串 当其中一个是的结果qsTr()函数和第二个是属性设置从C++吗?在QML中加入2个字符串
property string name: ""
function myFunction() {
myText.text = qsTr("My Name is: ") + name;
//myText.text = qsTr("My Name is: " + name);//another try
}
Text{
id: myText
text: ""
}
Button {
text: name
}
开按钮:John Smith
在文字:My Name is:
可能的复制[ QML中QString :: arg()的等价性是什么(https://stackoverflow.com/questions/12758282/what-is-the-equivalence-for-qstring) ARG-在-QML) – the4kman