Results 1 to 2 of 2

Thread: File Reading Advice

  1. #1
    Join Date
    Jun 2008
    Location
    UK
    Posts
    35
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default File Reading Advice

    Hi,

    I have a file with 400 bytes of data that i need to read in to a set of variables, the data is stored in the file exactly as it was in memory, so for example the first few bytes of the file are as follows:

    2 bytes : unsigned short
    255bytes : QByteArray
    2 bytes : unsigned short
    8 bytes: double
    ....

    I need to read these bytes into variables of respective data types, and im a bit unsure how to do this.

    Can anyone give me some pointers on how to approach this, i.e if i need to use text or data streams, or just QFile?

    Thanks alot,

    Jack

  2. #2
    Join Date
    Dec 2006
    Posts
    849
    Thanks
    6
    Thanked 163 Times in 151 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: File Reading Advice

    if you have written it with a QDataStream: read it using one.
    otherwise, read it the way you wrote it. probably read some bytes into a char buffer, use reinterpret_cast and assign it to integers etc.

Similar Threads

  1. help in reading XML file
    By cshiva_in in forum Qt Programming
    Replies: 1
    Last Post: 24th March 2008, 13:55
  2. QTextStream loses position while reading file
    By bjh in forum Qt Programming
    Replies: 2
    Last Post: 13th February 2008, 15:47
  3. Replies: 3
    Last Post: 18th October 2007, 18:07
  4. QWT 5, QT3, SuSE 10.2. Crash and burn
    By DrMcCleod in forum Qwt
    Replies: 8
    Last Post: 7th September 2007, 20:53
  5. qt-3.3.8 fail in scratchbox
    By nass in forum Installation and Deployment
    Replies: 0
    Last Post: 25th May 2007, 15:21

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.