Results 1 to 15 of 15

Thread: Bitwise shifting and ORing HexaDecimal Value

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #12
    Join Date
    Nov 2010
    Posts
    100
    Thanks
    38
    Thanked 1 Time in 1 Post
    Qt products
    Qt3 Qt4

    Default Re: Convert QByteArray to quint 16

    Hello ChrisW thank you so much for taking time and helping me out with my problem.

    I have a doubt i actually wanted Each byte in the QByteArray to be of 16-bits size.?
    I think now each byte is QByteArray is of 8-bits. So i am loosing the data,
    only the first 8 bits are taken so i am loosing the other 8 bits. I am getting only "b7" . If i have a 16-bit size for each byte then i will get the right data.
    Qt Code:
    1. ORed = 0000 0011 1011 0111
    2. 0 3 b 7
    To copy to clipboard, switch view to plain text mode 
    This is how i tried your code but i din't get any value appended to the Text Browser.
    Is this the right way to do it.
    Qt Code:
    1. QByteArray result;
    2. ba[0] = 0x1d;
    3. ba[1] = 0x17;
    4. ba[2] = 0x11;
    5. ba[3] = 0x00;
    6. for (int i = 0; i < ba.size(); i+=2)
    7. {
    8. //result.append(((ba.at(i) << 5)|(ba.at(i+1))));
    9. quint16 result=((static_cast<unsigned int>(ba.at(i) << 5))|(static_cast<unsigned int>(ba.at(i+1))));
    10.  
    11. }
    12. da.append(result.toHex());
    13. textBrowser->append(da);
    To copy to clipboard, switch view to plain text mode 

    If i have each byte in QByteArray ba; as 16-Bits size. i think my problem will be solved.How do you think i should do it Chris. ?

    regards
    Last edited by nagabathula; 17th November 2010 at 09:01.

Similar Threads

  1. Shifting a QImage up by 1 pixel row
    By MSUdom5 in forum Qt Programming
    Replies: 2
    Last Post: 7th May 2010, 10:25
  2. LineEdit for Hexadecimal input
    By mastupristi in forum Qt Programming
    Replies: 2
    Last Post: 21st January 2010, 14:51
  3. how to process hexadecimal
    By mohanakrishnan in forum Qt Programming
    Replies: 2
    Last Post: 20th November 2009, 04:33
  4. Byte shifting in C
    By tntcoda in forum General Programming
    Replies: 3
    Last Post: 14th November 2008, 22:40
  5. Replies: 2
    Last Post: 4th August 2008, 08:14

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
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.