Results 1 to 2 of 2

Thread: Storing hex in QBytearray, extracting it and converting it to decimal

  1. #1
    Join Date
    Apr 2011
    Posts
    231
    Thanks
    141
    Thanked 6 Times in 5 Posts

    Default Re: Storing hex in QBytearray, extracting it and converting it to decimal

    Qt Code:
    1. int dd = 0xA5;
    2.  
    3. p.push_back (0xA5);
    4. qDebug () << "SOP: " << (int)p[0];
    To copy to clipboard, switch view to plain text mode 

    This results in -91 whereas 0xA5 stands for 165 in decimal.

    How to store hex in QBytearray, extract it and convert it to decimal?


    Added after 11 minutes:


    This helped: http://www.qtcentre.org/threads/2959...019#post139019

    Also, I could have casted it to unsigned char.
    Last edited by TheIndependentAquarius; 18th March 2016 at 11:22.

  2. #2
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    5,230
    Thanks
    302
    Thanked 864 Times in 851 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: Storing hex in QBytearray, extracting it and converting it to decimal

    Yep. 256 - 91 = 165 last time I checked.

Similar Threads

  1. String ( QbyteArray ) to Double Value with 6 decimal digits
    By persianpatient in forum Qt Programming
    Replies: 2
    Last Post: 30th August 2015, 21:43
  2. Parsing/extracting from a binary QByteArray
    By Phlucious in forum Qt Programming
    Replies: 4
    Last Post: 2nd December 2011, 19:15
  3. Extracting int values from QByteArray
    By Tottish in forum Newbie
    Replies: 4
    Last Post: 7th April 2010, 10:41
  4. storing integer 4bytes in QByteArray
    By babu198649 in forum Newbie
    Replies: 2
    Last Post: 30th November 2008, 10:08
  5. converting the value from hexadecimal to decimal value
    By jjbabu in forum Qt Programming
    Replies: 2
    Last Post: 16th November 2007, 10:24

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.