Hi
I have a little problem, exactly i have no idea how to replace sentens in txt file...
In txt file i have something like thath
Do u know how to change value 0 to 1 in dir exp?
Best regards
Hi
I have a little problem, exactly i have no idea how to replace sentens in txt file...
In txt file i have something like thath
Do u know how to change value 0 to 1 in dir exp?
Best regards
If you don't change the length, you can seek to the position in the file and simply overwrite the character. But if you want something more complicated, you'll have to read the file into memory (into a string or sth), replace what you want and write everything back.
There are several options:
1. It looks you are dealing with an ini file.
So you might want to have a look at QSettings, which does all this for you.
2. if for some reason you can't use QSettigns, but you know exactly what you are looking for in the text (meaning, the text is not arbitrary ) you can just use QString::replace()
3. If the text to replace is not fixed, then you can use QRegExp in conjunction with QString.
4. If none of the above helped you, you might want to look QTextEdit facilities, but in contrast to the previous points, its not as little code as the others.
==========================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.
Zergi (25th December 2007)
Bookmarks