You Are Here:

Community: Wiki

This page was last modified on 30 October 2009, at 16:06.

How to perform file IO using QDataStream in Qt for Symbian

From Forum Nokia Wiki

Reviewer Approved   



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


Overview

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.

Preconditions


Various Functions

  • Sets the serialization byte order to bo.
in.setByteOrder(QDataStream::LittleEndian);
  • Sets the version number of the data serialization format to v
QDataStream out(file);
out.setVersion(QDataStream::Qt_4_0);


Source File

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

Related Wiki Articles

No related wiki articles found

Rate This

 
Bookmark this page: DeliciousDiggFacebookGoogleYahooStumbleUponRedditDiigoTechnocratiTwitter  Share this page Share this page Print this Page Print this page Invite a friend Invite a friend
京ICP备05048969号    Email Newsletters Press Terms & Conditions Privacy Policy Sitemap Contact Us © 2009 Nokia 
RDF Facets: qdcZidentifierQSxhttpE3aE2fE2fwikiE2eforumE2enokiaE2ecomE2findeE78E2ephpE2fComboBoE78E5fwithE5fcolorE5fpalettesE5finE5fE51tE5fforE5fSymbianX qdcZtypeQUqfnZE45E78cludedFromGeneralE4cistingsQ qdcZtypeQUqfntypeZCommunityContentQ qdcZtypeQUqfntypeZE52esourceQ qdcZtypeQUqfntypeZWebpageQ qdcZtypeQUqfntypeZWikiContentQ qdcZtypeQUqmarsZManagedE52esourceQ qdcZtypeQUqwebZInformationE52esourceQ qdcZtypeQUqwebZPageQ qdcZtypeQUqwebZE52esourceQ qdcZtypeQUqrdfsZE52esourceQ qfnZtopicQUqfnTopicZE71tQ qfnZtypeQUqfntypeZCommunityContentQ qfnZtypeQUqfntypeZE52esourceQ qfnZtypeQUqfntypeZWebpageQ qfnZtypeQUqfntypeZWikiContentQ qfnZuserE5ftagQSxE71tX qmarsZlanguageQUxhttpE3aE2fE2fswE2enokiaE2ecomE2flanguageE2d1E2fenX qrdfZtypeQUqfnZE45E78cludedFromGeneralE4cistingsQ qrdfZtypeQUqfntypeZCommunityContentQ qrdfZtypeQUqfntypeZE52esourceQ qrdfZtypeQUqfntypeZWebpageQ qrdfZtypeQUqfntypeZWikiContentQ qrdfZtypeQUqmarsZManagedE52esourceQ qrdfZtypeQUqwebZInformationE52esourceQ qrdfZtypeQUqwebZPageQ qrdfZtypeQUqwebZE52esourceQ qrdfZtypeQUqrdfsZE52esourceQ