Results 1 to 2 of 2

Thread: Start writing from a specific line in a file

  1. #1
    Join Date
    Jul 2011
    Posts
    16
    Thanks
    8
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Start writing from a specific line in a file

    Hello Folks,

    I have some data that i saved to file.txt. The data looks like:

    abc
    def
    ghi
    123
    456
    678
    .
    .
    .

    I have no commas in the file, and each column has only one value.

    What i want to do is to start writing from a specific line. For example, start writing from the 3rd line and change the content to the 9th line.

    How can i do that please ?

    Thank you in advance,

  2. #2
    Join Date
    May 2011
    Posts
    239
    Thanks
    4
    Thanked 35 Times in 35 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Symbian S60

    Default Re: Start writing from a specific line in a file

    The easiest way is to do it is in memory. Read the file into a QStringList, change the lines (now QStrings) and write the whole thing back to the file.

  3. The following user says thank you to mvuori for this useful post:

    nackasha (17th August 2011)

Similar Threads

  1. New line when writing a File
    By locke in forum Qt Programming
    Replies: 5
    Last Post: 17th May 2011, 11:27
  2. Read a specific line from a file
    By rleojoseph in forum Qt Programming
    Replies: 11
    Last Post: 21st March 2011, 11:58
  3. Image reading and writing line by line
    By Astrologer in forum Qt Programming
    Replies: 7
    Last Post: 29th April 2010, 08:15
  4. Writing to file at specific
    By safknw in forum Qt Programming
    Replies: 3
    Last Post: 1st December 2006, 11:12
  5. how to move cursor to specific line in Text
    By showhand in forum Qt Programming
    Replies: 1
    Last Post: 24th August 2006, 09:55

Tags for this Thread

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
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.