Results 1 to 6 of 6

Thread: Convert 2 bytes of raw data to qint16

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #2
    Join Date
    Apr 2013
    Location
    Prague
    Posts
    258
    Qt products
    Qt4
    Platforms
    Unix/X11
    Thanks
    3
    Thanked 65 Times in 59 Posts

    Default Re: Convert 2 bytes of raw data to qint16

    Qt Code:
    1. quint16 res = *reinterpret_cast<const quint16 *>(&buffer1.constData[i]); // if you want 0xFE45
    2.  
    3. res = ((res << 8) | (res >> 8)); // if you want 0x45FE
    To copy to clipboard, switch view to plain text mode 
    Last edited by Radek; 23rd March 2014 at 19:28.

  2. The following user says thank you to Radek for this useful post:

    Smosia (23rd March 2014)

Similar Threads

  1. Store data in bits & Bytes
    By 2lights in forum Newbie
    Replies: 3
    Last Post: 9th September 2013, 13:39
  2. Replies: 4
    Last Post: 23rd October 2012, 08:40
  3. Replies: 7
    Last Post: 12th September 2011, 10:52
  4. Convert int to Hex with fixed bytes
    By metRo_ in forum Qt Programming
    Replies: 3
    Last Post: 7th September 2011, 16:31
  5. How to convert binary data to hexadecimal data
    By yellowmat in forum Newbie
    Replies: 4
    Last Post: 8th March 2006, 16:17

Tags for this Thread

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
  •  
Qt is a trademark of The Qt Company.