| ID | ... | Creation date | 27 January 2009 |
| Platform | S60 3rd Edition FP1, S60 3rd Edition FP2, S60 5th Edition | Tested on devices | Emulator |
| Category | Qt for Symbian | Subcategory |
| Keywords (APIs, classes, methods, functions): QDataStream |
This code snippet demonstrates how to use QDataStream for performing file read and write in Qt for S60.
In my previous article same function would be perform using QTextStream.
in.setByteOrder(QDataStream::LittleEndian);
QDataStream out(file); out.setVersion(QDataStream::Qt_4_0);
More About QDataStream: http://pepper.troll.no/s60prereleases/doc/qdatastream.html
#include "fileIO.h"
#include <QFile>
#include <QLabel>
#include <QDataStream>
fileIO::fileIO(QWidget *parent)
: QWidget(parent)
{
QFile file("c://test.txt");
file.open(QIODevice::WriteOnly);
QDataStream out(&file); // we will serialize the data into the file
out << "welcome to the Qt World"; // serialize a string
file.close();
QFile read("c://test.txt");
read.open(QIODevice::ReadOnly);
QDataStream in(&read); // read the data serialized from the file
QString str;
in >> str;
}
fileIO::~fileIO()
{
}
More About QDataStream: http://pepper.troll.no/s60prereleases/doc/qdatastream.html