You do not need or want to use QDataStream for this task. As Wysota points out a simple call to QIODevice::read() or readAll() will suffice. As mcosta points out you are flirting with crashing by using a char* pointer that is not initialised to point at allocated memory: Qt provides structures to handle this for you.
Your problem comes down to:
- Open file and report error if file not opened: See QFile and QIODevice open() and errorString().
- Read file content into memory. See QByteArray and QIODevice::read() or readAll().
- Close file. See QFile::close()
- Do something with content. See QByteArray::toHex()
That description is about the same length as a basic implementation.
Bookmarks