Results 1 to 7 of 7

Thread: Binary file reading using Structure

  1. #1
    Join Date
    Jul 2009
    Posts
    49
    Thanks
    9
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Binary file reading using Structure

    Hai

    I want to use structure in my program to read binary file


    typedef struct {
    qint16 emptyData;
    qint32 runno;
    } CommonData;
    CommonData CD;
    dataStm>>CD; // dataStm-> QDATASTREAM , code not working....



    succession please..

    suresh R
    India

  2. #2
    Join Date
    Jun 2007
    Location
    India
    Posts
    1,042
    Thanks
    8
    Thanked 133 Times in 128 Posts
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Binary file reading using Structure

    you have to overload operator<<() and operator>>() for your struct

  3. #3
    Join Date
    Jul 2009
    Posts
    49
    Thanks
    9
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Binary file reading using Structure

    thanks



    I want detailed code please

  4. #4
    Join Date
    Jan 2006
    Location
    Germany
    Posts
    4,380
    Thanks
    19
    Thanked 1,005 Times in 913 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60
    Wiki edits
    5

    Default Re: Binary file reading using Structure

    Quote Originally Posted by umulingu View Post
    I want detailed code please
    ...and I want users who at least try to solve their own problems, before bothering us to deliver a complete solution!

  5. The following user says thank you to Lykurg for this useful post:

    umulingu (25th July 2009)

  6. #5
    Join Date
    Jul 2009
    Posts
    49
    Thanks
    9
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Binary file reading using Structure

    thanks for ur suggestion



    I will try ..............

  7. #6
    Join Date
    Jan 2008
    Posts
    107
    Thanks
    36
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Binary file reading using Structure

    Quote Originally Posted by MrDeath View Post
    you have to overload operator<<() and operator>>() for your struct
    MrDeath,

    I'm also interested in knowing how this overloading works as I've tried it without success...
    TIA,
    Pedro.

  8. #7
    Join Date
    Jan 2006
    Location
    Germany
    Posts
    4,380
    Thanks
    19
    Thanked 1,005 Times in 913 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60
    Wiki edits
    5

    Default Re: Binary file reading using Structure

    Take any book for c++, there will be a lot of examples how to overload a operator. For debug and struct use
    Qt Code:
    1. friend QDebug operator<<(QDebug out, const YourStruct &s)
    2. {
    3. //...
    4. }
    To copy to clipboard, switch view to plain text mode 
    The text stream works equal. And the place for the deklaration/definition you will find...

  9. The following 2 users say thank you to Lykurg for this useful post:

    pdoria (25th July 2009), umulingu (27th July 2009)

Similar Threads

  1. Reading characters in Binary file.....
    By umulingu in forum Qt Programming
    Replies: 2
    Last Post: 23rd July 2009, 04:51
  2. Binary file Reading.........
    By umulingu in forum Qt Programming
    Replies: 11
    Last Post: 20th July 2009, 06:18
  3. reading 4-bytes integer from binary file
    By maka in forum Qt Programming
    Replies: 8
    Last Post: 12th May 2009, 05:57
  4. Read binary from file
    By weldpua2008 in forum Newbie
    Replies: 2
    Last Post: 3rd April 2009, 23:50
  5. Reading binary data
    By vermarajeev in forum Qt Programming
    Replies: 1
    Last Post: 13th August 2007, 09:14

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.