Results 1 to 6 of 6

Thread: Create file and read text with QFile and QTextStream

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #3
    Join Date
    Jan 2006
    Location
    travelling
    Posts
    1,116
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows
    Thanks
    8
    Thanked 127 Times in 121 Posts

    Default Re: Create file and read text with QFile and QTextStream

    Quote Originally Posted by auba View Post
    It works this way: when you only put \n at the end of a line, Notepad on Win32 will not display the text correctly. If you put \r\n at the end, vi will display ^M at the end of each line.
    If only QT-Apps use the file, you can use endl and ignore all other editors, else you'll have to replace \r\n or \n to what you want before loading/saving.
    Small corrections :

    • when opening the device (QFile or any QIODevice) in Text mode, you can just use the LF ('\n') character as it is automatically converted into local line endings (may it be LF, CR or CRLF)
    • conversely, when reading a file opened in Text mode local line endings are converted into LF to make it easier to process the content without having to mess with line endings
    • this issue is purely independent of Qt, nowadays most applications are able to read files of any line endings (even Wordpad does it)
    Current Qt projects : QCodeEdit, RotiDeCode

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

    jano_alex_es (26th May 2009)

Similar Threads

  1. How to read line from file
    By Krishnacins in forum Newbie
    Replies: 10
    Last Post: 1st June 2006, 23:14
  2. QSettings vs (QFile + Qtextstream)
    By nupul in forum Newbie
    Replies: 5
    Last Post: 10th April 2006, 07:26
  3. segfault on qtextstream
    By patcito in forum Qt Programming
    Replies: 13
    Last Post: 26th February 2006, 13:10

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.