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

问题描述 投票:-2回答:1

我想替换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)

请帮我....

c++ qt qml
1个回答
-1
投票
while (szString[2].search("#") > -1) szString[2] = szString[2].replace("#"," ")
© www.soinside.com 2019 - 2024. All rights reserved.