我使用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