smaica
smaica

Reputation: 817

QStringList::split - split a long string with data into many different QString

I have a long list of data that contains data as follows:

"floatingnumber1a:floatingnumber1b,floatingnumber2a:floatingnumber2b,floatingnumber3a:floatingnumber3b"

I have them as a QString. Now I want to split them in two different arrays - one that contains the floatingnumbera values and one with floatingnumber b.

How can I do this? Maybe first I split them at each "," create a List with QStrings and then split each of them at the ":" to have two seperated strings which I can convert to double?!

But I don't know how to manage this.

I tried split():

QStringList parts1 = data.split(",");

but whats than?

Upvotes: 0

Views: 745

Answers (1)

Some programmer dude
Some programmer dude

Reputation: 409176

First split the string on comma, then split each sub-string on colon, then convert the sub-sub-strings into floating-point numbers and add to respective collection.

Upvotes: 2

Related Questions