Results 1 to 2 of 2

Thread: Endian

  1. #1
    Join Date
    Oct 2007
    Posts
    78
    Thanks
    1
    Thanked 3 Times in 3 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Endian

    If I am using

    Qt Code:
    1. QLineEdit *le = new QLineEdit();
    2. le->setText("aabbccdd");
    3.  
    4. QByteArray hexData = QByteArray::fromHex(le->text().toAscii());
    To copy to clipboard, switch view to plain text mode 

    Is QByteArray going to encode it by the systems endian or is going to respect the order given in the QLineEdit?

    Qt Code:
    1. qebug() << hexData.toHex();
    To copy to clipboard, switch view to plain text mode 

    Debug appears to keep the byte order given, but if I am to use QByteArray::toInt() and back to hex etc do I need to track endian or will Qt do it for me?

    Bob

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Endian

    Quote Originally Posted by coderbob View Post
    Is QByteArray going to encode it by the systems endian or is going to respect the order given in the QLineEdit?
    QByteArray operates on bytes, which don't suffer from endianness. fromHex() will process the string from left to right replacing every two characters with a single byte.

    Debug appears to keep the byte order given, but if I am to use QByteArray::toInt() and back to hex etc do I need to track endian or will Qt do it for me?
    You don't have to worry about endianness as long as you don't do any casts or pass data between systems.

Similar Threads

  1. Replies: 3
    Last Post: 26th July 2006, 13:41

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.