Answer the question
In order to leave comments, you need to log in
How to get the bytes of a class instance?
Hello!
It was necessary to write the binary value of the class instance into the byte stream. I wanted to implement similar to the overloaded << for QDataStream:
QByteArray arrBlock;
QDataStream binaryStream(&arrBlock, QIODevice::WriteOnly);
binaryStream << QPixmap();
Answer the question
In order to leave comments, you need to log in
Here is the answer to the question, but it does not apply to QPixmap , QPixmap::save should be used there..
#pragma pack(push, 1)
struct MyStruct
{
qint64 varA;
qint64 varB;
};
#pragma pack(pop)
MyStruct myStruct;
myStruct.varA = 234;
myStruct.varB = 4534;
QByteArray structByteArray(reinterpret_cast<const char*>(&myStruct), sizeof(MyStruct));
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question