Results 1 to 3 of 3

Thread: QTextStream and file handle

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #2
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,714
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows
    Thanks
    21
    Thanked 418 Times in 411 Posts

    Default Re: QTextStream and file handle

    In my case it points to "abc.txt"
    This surprises me, and I tend to think that either the code you posted is not 100% the same as you really use it, or, something else that you do.
    The stream is not 'pointing' to anything, it takes a reference to a QFile (actually a QIODevice) object.
    This means, the stream doesn't know anything about the file name - it just streams to the device it has a reference to, and that device may have any filename what so ever - the QFile object is reposible for opening the physical file, not the stream.

    Make sure you are not setting a different file name to an already open QFile object.
    ==========================signature=============== ==================
    S.O.L.I.D principles (use them!):
    https://en.wikipedia.org/wiki/SOLID_...iented_design)

    Do you write clean code? - if you are TDD'ing then maybe, if not, your not writing clean code.

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

    Dilshad (4th January 2011)

Similar Threads

  1. Replies: 0
    Last Post: 17th June 2010, 11:07
  2. writing file with QTextStream
    By Raul in forum Qt Programming
    Replies: 3
    Last Post: 31st May 2010, 14:46
  3. Replies: 5
    Last Post: 27th May 2009, 12:49
  4. QTextStream loses position while reading file
    By bjh in forum Qt Programming
    Replies: 2
    Last Post: 13th February 2008, 15:47
  5. Reading File using QFile and QTextStream
    By atm in forum Qt Programming
    Replies: 4
    Last Post: 13th July 2006, 23:12

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.