Discussion Board

Results 1 to 2 of 2
  1. #1
    Regular Contributor
    Join Date
    Apr 2011

    On QFile::readAll()

    I have a code like this:
         QByteArray content= file->readAll();
         qDebug()<<"File size is "<<file->size();
         qDebug()<<"Array1 size is "<<content.size();
    I got the result:
    File size is 77274
    Array size is 1543

    I have also get this:
            qDebug()<<"readAll() size is "<<reply->readAll().size();
    The file content is normal, but readAll() size is 0

    This why. I think readAll() will read all lines from the file and they should at least has similar size.
    Last edited by useryy2; 2011-06-28 at 08:49.

  2. #2
    Regular Contributor
    Join Date
    Apr 2011

    Re: On QFile::readAll()

    Got the answer: QFile is derived from QIODevice, which once "readAll()", the source data is flushed.
    So I change it to: QByteArray bArray = reply->readAll()
    and use bArray to do everything later.

Similar Threads

  1. Replies: 3
    Last Post: 2011-01-27, 18:14
  2. Fill struct using QFile
    By NMMA in forum Qt
    Replies: 5
    Last Post: 2010-07-05, 16:50
  3. QFile problem
    By BalajiR in forum Qt
    Replies: 9
    Last Post: 2010-03-04, 05:49

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts