PDA

View Full Version : Convert data in QVector<QString> to Decimal



rex
10th February 2011, 12:31
Hello every one.. I have a small problem.. i have some data in a QVector<QString> temperaturedata; which i need to convert into Hexadecimal. But QVector does't have a property like QString toInt(0,16) or toInt(0,10), i am doing this right now,

str = QString::number(listdata.toInt(0,16));
to convert the Hexadecimal data i have in listdata into Decimal. and then i am appending it into a QVector<QString> to dump into the data base, I wanted to use
QVector<QString> only directly so that i can convert it into Decimal in the QVector itself..?

thank you

JohannesMunk
10th February 2011, 15:22
I have read your text 4 times and still don't have a clue a) what you want to achieve and b) where your problem is!

Could you please clearly state what you want to do and where exactly you fail doing it? Maybe it would help to see a bit more of your code to grasp what is going where.

Joh

ChrisW67
11th February 2011, 01:31
One seriously confused post :confused:

You have a list of strings. The name have given the list implies that each string is the representation of a temperature (decimal string, hex string, integer or real values, what?). You tell us you want to convert this list, or some part of it, to hexadecimal (another string format) according to the post body, or decimal according to the post title.

You then tell us about some undefined variable listdata that we can infer is a hexadecimal string from your attempt to convert it to an integer. Then you convert it back to a decimal string.

None of this seem to have much to do with the actual question. Ultimately it seems the only things you are missing are using a loop to iterate over the vector (see the QVector docs), and assigning to an element in the vector. Have a look at QVector::operator[].