PDA

View Full Version : Endian



coderbob
30th November 2007, 00:49
If I am using



QLineEdit *le = new QLineEdit();
le->setText("aabbccdd");

QByteArray hexData = QByteArray::fromHex(le->text().toAscii());



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



qebug() << hexData.toHex();


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

jacek
30th November 2007, 11:49
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.