You are not logged in.

Dear visitor, welcome to QtForum.org. If this is your first visit here, please read the Help. It explains in detail how this page works. To use all features of this page, you should consider registering. Please use the registration form, to register here or read more information about the registration process. If you are already registered, please login here.

nass

Trainee

  • "nass" is male
  • "nass" started this thread

Posts: 57

Location: Greece

Occupation: Software Engineer

  • Send private message

1

Thursday, September 21st 2006, 1:19pm

accessing data in a QFile

hello everyone,
i have been ssaving some variable values in a file using QFile and QDataStream.
the variables are of types Q_UINT8, Q_INT8, Q_UINT32, Q_INT32, float, double and even QString...
write and read operation work wonderfully so far..

but now i need to be able to access certain variables down the stream..
so if i have written the stream in the file as:

QDataStream ds(&aQFile)
ds<<aUINT8<<aUINT32<<aINT8<<aFloat<<aDouble<<aQString<<anotherINT8..... etcetc

and now i want to access directly aINT8, how do i do it?
i read in te documentation at the QFile::at(Offset off) function... i guess the offset is just an integer number of the counted bytes till the beginning of the variable i want to read..
however i wonder how im gonna compute the offsets..
mean in the above case its easy to find the offset of aINT8.. it is 5 (bytes) ... or not?
however how can i get the offset of anotherINT8 ?
thank you for your help
nass

AP.Sakkthivel

Professional

  • "AP.Sakkthivel" is male

Posts: 563

Location: India

Occupation: Application Development Using Qt

  • Send private message

2

Friday, September 22nd 2006, 4:45am

I am not sure about your qt version..

In qt 4, QDataStream has an api to locate a particular byte.

No worry...refer QDataStream class well
Regards
- $akthi

You never know, how soon it may be too late…