Maybe you can ask chatgpt.....
This answer is from deepseek:
To convert the JavaScript function int64LE to Qt, you need to create a QByteArray that holds the little-endian byte representation of a 64-bit signed integer. Here's the step-by-step solution:
Resize the QByteArray to hold 8 bytes (64 bits).
Cast the input quint64 number to qint64 to handle it as a signed integer.
Extract each byte in little-endian order by masking and shifting the value.
Store each byte in the QByteArray.
QByteArray UtilsEssp::int64LE(quint64 number)
{
QByteArray buffer;
buffer.resize(8); // Allocate 8 bytes
qint64 value = static_cast<qint64>(number); // Treat as signed
// Extract each byte in little-endian order
for (int i = 0; i < 8; ++i) {
buffer[i] = static_cast<char>(value & 0xFF);
value >>= 8;
}
return buffer;
}
Explanation:
Resizing the Buffer: buffer.resize(8) ensures the QByteArray has space for 8 bytes.
Casting to Signed: static_cast<qint64>(number) converts the unsigned input to a signed 64-bit integer, preserving the bit pattern.
Little-Endian Extraction: The loop iterates 8 times, each time taking the least significant byte using value & 0xFF, then right-shifting value by 8 bits. This fills the QByteArray from the least significant byte to the most significant, achieving little-endian order.
This approach mirrors the original JavaScript functionality by directly manipulating the byte representation, ensuring compatibility with systems expecting a signed 64-bit integer in little-endian format.