PDA

View Full Version : How can I read binary data to QString?



zolookas
29th July 2008, 17:07
Can I read binary data (for example 9 bytes) directly to QString from file? fread does not work with QString for me (requires char*), QDataStream also requires char* and serialized data example (http://doc.trolltech.com/4.3/qdatastream.html) does not appear to be sutable for binary data.

lvi
29th July 2008, 17:54
How about using QDataStream::readRawData()?

http://doc.trolltech.com/4.3/qdatastream.html#raw

edit: Nevermind, I misread your post. Sorry...

Can you use QString::data() and cast that (QChar) pointer to a regular char* ?

jpn
29th July 2008, 20:03
QByteArray is the appropriate class are when you need to store raw binary data.