Results 1 to 2 of 2

Thread: Reading of a Particular line & replacing its text after particular character

  1. #1
    Join Date
    Oct 2012
    Location
    Gurgaon, Haryana, India
    Posts
    15
    Thanks
    5
    Qt products
    Qt4
    Platforms
    Windows

    Question Reading of a Particular line & replacing its text after particular character

    Hello Everyone,

    I have an application in which i want to create file to store some string from different location.
    (Say)
    "stylesheetfile: abc.txt" from a function & "Languagefile: xyz.txt" form another function.

    If Particular line not present if file then store that line, otherwise, read that line & based on Languagefile:/stylesheetfile: replace rest of line.

    Thanks in Advance for your valuable help.

    Regards
    Pardeep Sharma

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,360
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Reading of a Particular line & replacing its text after particular character

    It is not possible to "replace" a line in file (unless the replacement has exactly the same number of bytes as the part being replaced) and neither it is possible to "insert" a line in the middle of a file. If you need something like this, you have to rewrite every successive byte of the file. So it's usually easier to just read the file to memory, modify it there and then write everything back.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


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


Similar Threads

  1. QRegExp not reading literal character '-'
    By jshafferman in forum Qt Programming
    Replies: 5
    Last Post: 17th April 2012, 15:53
  2. Reading a text line per line
    By Momergil in forum Newbie
    Replies: 0
    Last Post: 19th July 2011, 15:46
  3. QTextEdit End-of-Line character
    By smhall316 in forum Newbie
    Replies: 1
    Last Post: 29th September 2010, 18:28
  4. Image reading and writing line by line
    By Astrologer in forum Qt Programming
    Replies: 7
    Last Post: 29th April 2010, 08:15
  5. Character by Character (Unicode?) File Reading
    By mclark in forum Qt Programming
    Replies: 4
    Last Post: 22nd April 2009, 15:28

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.