Results 1 to 7 of 7

Thread: Read binary file into 2 QVectors

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Apr 2012
    Posts
    21
    Thanks
    5
    Qt products
    Qt4
    Platforms
    Windows

    Default Read binary file into 2 QVectors

    Hello, I have one question about reading binary files.

    I wrote data like this:
    Qt Code:
    1. QVector<QPoint> p;
    2.  
    3. QFile binfile(path);
    4. binfile.open(QIODevice::WriteOnly);
    5. QDataStream out(&binfile);
    6.  
    7. out << p;
    To copy to clipboard, switch view to plain text mode 


    ..and tried reading it this way:
    Qt Code:
    1. QFile bin(fileName);
    2. bin.open(QIODevice::ReadOnly);
    3. QDataStream in(&bin);
    4.  
    5.  
    6. QVector<qint32> x, y;
    7.  
    8. in >> x >>y;
    To copy to clipboard, switch view to plain text mode 


    I know this isn't the right way to read this kind of data,
    so can anyone help me to put binary data into two vectors, x and y.

    Data is written into binary file as a list of points: x1 y1 x2 y2 x3 y3..
    ..and i should read first all x coordinates to x vector and all y coordinates to y vector..
    Last edited by juracist; 17th May 2012 at 18:41.

Similar Threads

  1. Read binary file
    By jaca in forum Qt Programming
    Replies: 9
    Last Post: 28th March 2012, 08:38
  2. Max and min from QVector<QPoint>
    By awpitt13 in forum Newbie
    Replies: 4
    Last Post: 14th February 2012, 01:18
  3. Read a Byte from Binary File
    By umulingu in forum Qt Programming
    Replies: 1
    Last Post: 3rd March 2010, 06:20
  4. Read binary from file
    By weldpua2008 in forum Newbie
    Replies: 2
    Last Post: 3rd April 2009, 23:50
  5. Read binary file and convert to QString
    By jaca in forum Qt Programming
    Replies: 12
    Last Post: 13th June 2008, 23:05

Tags for this Thread

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.