I\'m struggling with writing a struct
to a file via QFile
in Qt.
typedef struct {
uint32_t timestamp;
uint32_t recordType;
Much simpler:
assuming your structure 'DataPacket'
void MyClass::write()
{
QFile out(FILE_PATH_NAME);
out.open(QIODevice::WriteOnly);
out.write((const char *)DataPacket,sizeof(DataPacket));
out.close();
}
void MyClass::read()
{
QFile in(FILE_PATH_NAME);
in.open(QIODevice::ReadOnly);
in.read((const char *)DataPacket,sizeof(DataPacket));
in.close();
}