如何在QT QML中替换变体数组文本

时间:2017-11-30 01:34:59

标签: c++ qt qml

我想替换qml中的字符串文本。 例如, 存在QML变体数组。我用它来发短信。

property variant    szString: ["", "", "", "", "", "", "", "", "", ""]

i do data in szString.
szString[1] = "abcdefg"
szString[2] = "a###b"
...

Text: {
    text: szString[index]
    ...
}

我想在此文本中替换字符串。 例如,

i want szString[2].replace("#"," "). (i want result -- szString[2] = "a   b" )
but, the QML language can't apply.(szString.replace("#"," ") can apply, but this result isn't... i don't want result)

请帮助我....

1 个答案:

答案 0 :(得分:-1)

while (szString[2].search("#") > -1) szString[2] = szString[2].replace("#"," ")