Unsolved How do I work with raw binary files with QT
-
I don't want to do stuff with classes and different variables. I want to work with byte to byte. It has been hard to find it and I think that QT probably expects people to do it differently.
-
@AI_Messiah
What do you mean by this question? Classes/variables have nothing to do with "byte to byte" and/or "raw binary files".Qt allows you to read/write binary files via
QFile
.If by any chance you are talking about file serialization/deserialization of variables/structures, you can use
QFile
directly, you do not have to go viaQDataStream
. -
What I mean is that I want to read and write binary files. In a way that I know that the compiler will not add extra stuff. I want to read and write as char s and know that what I am working with is actually is what is in the file.
-
@AI_Messiah So use QFile as @JonB already suggested.
-
@AI_Messiah said in How do I work with raw binary files with QT:
I want to read and write as char s and know that what I am working with is actually is what is in the file.
Qt does not add anything extra when accessing binary files. Just use it. However, to be precise a
char
is not necessarily 8 bits in C++ (https://stackoverflow.com/a/9727504/6954968). Qt usesQByteArray
instead. I assume that on all platforms a single byte inQByteArray
always has 8 bits. If you read the documentation carefully,QFile
andQByteArray
will do exactly what you want.