I have some data types that I am trying to write to to a raw data file. I'm not using QDataStream because that writes some extra information about the data, like the length and order of data. I simply want a file that is only the bytes that I write, and will only be interpreted by someone who knows the correct order and size of the data types being written.
I am using QFile, with the write method qint64 QIODevice::write(const QByteArray &byteArray)
.
I have a few uint8_t, uint32_t and floats to write to the file. How can I transform this data into a QByteArray with no extra bytes?
Here is what I have so far:
void FileWriter::writeData(uint8_t status, uint8_t channel, uint32_t ticks, float source0, float source1){
QByteArray dataToWrite;
//some code to add the paramters to the dataToWrite array
this->file.write(dataToWrite);
}
A regular old style cast to char
gives me an implicit conversion changes signedness
error, so that wouldn't store the value correctly.
what is the proper way to copies these values into a QByteArray so I can write it to file?