How to write the BYTE* data to a QFile? I have binary data in BYTE*, I want to write that data completely to QFile. How to perform this. Please help me
How to write the BYTE* data to a QFile? I have binary data in BYTE*, I want to write that data completely to QFile. How to perform this. Please help me
I assume your BYTE is char type, then convert char* to QByteArray, something like this
Qt Code:
char* data; //binary data int length; //length of binary data QFile file; To copy to clipboard, switch view to plain text mode
I am using BYTE* configid; How to write this to QFile.
how do you fill the BYTE*?
memcpy(configid,buff,len);
here buff is QByteArray.
is there any problem usingQt Code:
To copy to clipboard, switch view to plain text mode
Yes, it just prints one ",". Thats all.
Then check what is going wrong,
- check if len is proper, set a break point at write and check the value of len
- check QFile is opened in binary write mode
If you mean that buff is a pointer to a QByteArray then this will not do what you are intending. If buff is the value of QByteArray::constData() then you are copying the data from the QByteArray (assuming len is meaningful). In any case you have invented work for yourself. If you have the data already in a QByteArray then don't copy is somewhere else before trying to put it in a file.
Qt Code:
// QByteArray buff; open.write(buff); file.close(); }To copy to clipboard, switch view to plain text mode
If you don't request the end-of-line translations with QIODevice::Text then no translation is done: it is a binary file... just a stream of bytes.
Bookmarks