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. #2
    Join Date
    May 2009
    Posts
    61
    Thanks
    5
    Thanked 6 Times in 6 Posts
    Qt products
    Qt3 Qt4
    Platforms
    MacOS X Unix/X11 Windows

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

    Quote Originally Posted by jano_alex_es View Post
    but if we don't have that file we need to create it first. How can we do that?
    Doc of QFile:pen says:
    Note: In WriteOnly or ReadWrite mode, if the relevant file does not already exist, this function will try to create a new file before opening it.
    Quote Originally Posted by jano_alex_es View Post
    On the other hand, seems like I just need to add "\n" in the middle of the string associated to QString in order to have different rows, is that true? does it work differently in Windows OS?
    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.

  2. The following user says thank you to auba 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.