OK, So I'm fairly new to the Qt5 QML framework. This would've been fairly easy in any other language such as Java etc. But I'm unable to accomplish this in QML.
Here's what I want to do: I want to take a long string that I've received from my c++ code separated by commas
property string: "Here,There,That,This"
and I want to split it up into separate strings. I've come to understand that you need to use a variant in the sense that I basically have the property
property variant stringlist
where, stringlist[0] = "Here" and stringlist[1] = "There" etc.
Does anyone have a suggestion for the code for a function that I can call to do it. I would like to refrain from needing a javascript addition to create this function. So please do try to suggest a QML centric function, if at all possible.
Item{
property string myString: "Here,There,That,This"
property variant stringList: myString.split(',')
Component.onCompleted: {
console.log(stringList[0]); //outputs 'Here'
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With