Results 1 to 2 of 2

Thread: Problem Regarding QFile....!

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #2
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Problem Regarding QFile....!

    You call readAll() in your if() conditions. That reads all data from the file.

    Assuming there was data, you enter the else part of your code, which then calls readAll() again.
    Since the file is at the end already, the result is an empty byte array.

    Better use QFile::size() to check if the file is not empty.

    And you don't need to specify QIODevice::Text when opening, you are not interpreting the content in any way.

    Cheers,
    _

  2. The following user says thank you to anda_skoa for this useful post:

    gunturrohith (27th November 2014)

Similar Threads

  1. Performance problem with QFile.
    By Abdeljalil in forum Qt Programming
    Replies: 1
    Last Post: 26th April 2014, 18:25
  2. Replies: 2
    Last Post: 6th May 2013, 08:06
  3. QFile reading problem
    By giblit in forum Qt Programming
    Replies: 6
    Last Post: 5th April 2013, 05:45
  4. Problem with QFileDialog and QFile
    By Basti300 in forum Newbie
    Replies: 2
    Last Post: 26th May 2010, 20:18
  5. Problem with QFile
    By viciv919 in forum Newbie
    Replies: 5
    Last Post: 17th March 2010, 16:04

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
  •  
Qt is a trademark of The Qt Company.