Answer the question
In order to leave comments, you need to log in
How to parse QByteArray to QVector?
Good day!
We have a QByteArray that contains
"2700\n1455\n762\1834\n" It is
necessary to make a QVector d array out of it, such that
d[0] = 2700, d[1]=1455, d[2] = 762, d[ 3] 1834.
Please tell me how can this be done?
Thank you!
Answer the question
In order to leave comments, you need to log in
First, use the .split() method to split it at the \n character. Get list from arrays.
Then, use the to_long method to convert each array into numbers and write it to the array.
Split the QByteArray by the separator '\n', each resulting element needs to be run through the analog of atoi, which I don't remember in Qt. It's not clear what the problem is.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question