Results 1 to 3 of 3

Thread: (solved) QByteArray vs ByteBuffer (Java)

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Feb 2016
    Posts
    21
    Qt products
    Qt5
    Platforms
    Unix/X11

    Default (solved) QByteArray vs ByteBuffer (Java)

    Please can anyone help me.

    how to i but a qlonglong to a ByteArray with this Order

    Example:

    In Java:

    Qt Code:
    1. Long n = 60243;
    2. ByteBuffer byteBufferData = ByteBuffer.allocate(16);
    3. byteBufferData.putLong(turnoverCounter);
    To copy to clipboard, switch view to plain text mode 
    I got this Array "0 0 0 0 0 0 -21 83 0 0 0 0 0 0 0 0"
    I only need the first 8 Bytes "0 0 0 0 0 0 -21 83"

    In Cpp (Qt5):

    Qt Code:
    1. qlonglong n = 60243;
    2. for(int i = 0; i != sizeof(n); ++i)
    3. {
    4. ba.append((char)((n & (0xFF << (i*8))) >> (i*8)));
    5. }
    To copy to clipboard, switch view to plain text mode 

    I got the right length but in other order;
    I got "83 -21 0 0 0 0 0 0"

    How can i reverse this? can i put this in the reverse order in the loop? Or is this any problem?


    Thx Chris
    Last edited by ckvsoft; 26th October 2016 at 23:07. Reason: solved

Similar Threads

  1. Replies: 6
    Last Post: 14th May 2014, 12:14
  2. Replies: 1
    Last Post: 22nd June 2011, 08:12
  3. Qt and Java
    By gmseed in forum General Discussion
    Replies: 1
    Last Post: 21st November 2009, 11:55
  4. [java] Sax
    By mickey in forum General Discussion
    Replies: 0
    Last Post: 29th September 2009, 09:42
  5. Replies: 9
    Last Post: 25th July 2009, 13:27

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.