Please note that as of October 24, 2014, the Nokia Developer Wiki will no longer be accepting user contributions, including new entries, edits and comments, as we begin transitioning to our new home, in the Windows Phone Development Wiki. We plan to move over the majority of the existing entries over the next few weeks. Thanks for all your past and future contributions.
How to perform file IO using QDataStream in Qt
This code snippet demonstrates how to use QDataStream for performing file read and write in Qt.
- Sets the serialization byte order to bo.
- Sets the version number of the data serialization format to v
QDataStream out(file); out.setVersion(QDataStream::Qt_4_0);
More About QDataStream: http://pepper.troll.no/s60prereleases/doc/qdatastream.html
QDataStream out(&file); // we will serialize the data into the file
out << "welcome to the Qt World"; // serialize a string
QDataStream in(&read); // read the data serialized from the file
in >> str;