Results 1 to 3 of 3

Thread: Convert data in QVector<QString> to Decimal

  1. #1
    Join Date
    Dec 2010
    Posts
    41
    Thanks
    12

    Default Convert data in QVector<QString> to Decimal

    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,
    Qt Code:
    1. str = QString::number(listdata.toInt(0,16));
    To copy to clipboard, switch view to plain text mode 
    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

  2. #2
    Join Date
    Feb 2007
    Location
    Karlsruhe, Germany
    Posts
    469
    Thanks
    17
    Thanked 90 Times in 88 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Convert data in QVector<QString> to Decimal

    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

  3. #3
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Question Re: Convert data in QVector<QString> to Decimal

    One seriously confused post

    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[].

Similar Threads

  1. Replies: 1
    Last Post: 4th August 2010, 18:13
  2. convert decimal seconds to QDateTime and back
    By mcarter in forum Qt Programming
    Replies: 2
    Last Post: 18th March 2010, 13:06
  3. [[SOLVED]]Can't get data from QVector
    By asieriko in forum Newbie
    Replies: 1
    Last Post: 13th December 2009, 20:55
  4. convert QString to int
    By mattia in forum Newbie
    Replies: 2
    Last Post: 4th January 2008, 10:10
  5. How to convert binary data to hexadecimal data
    By yellowmat in forum Newbie
    Replies: 4
    Last Post: 8th March 2006, 17:17

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.