PDA

View Full Version : How to modify the content of text file



grsandeep85
31st July 2009, 11:13
Hi All,

i have a text file in the format
#n X Y Z
0 123 456 789
1 321 654 987
2 345 243 809
......
.....
...... and so on

the user inputs a linenumber of the text file from the number lineEdit the corresponding X,Y,Z values of that line i am able to read and put into the corresponding lineedits.now i need to modify the contents of linenumber and again write into the same file, please help us how to do this.

nish
31st July 2009, 11:16
its really irritating and ridiculously funny that you are still stuck with just reading a text file and posting similar topics again .. that too with a powerfull Qt toolkit at your disposal.. nobody can code for you.. what did you already tried?

grsandeep85
31st July 2009, 11:20
I am able to read the particluar line number now i am not able to modify the content of the same linenumber again write back into the text file.

nish
31st July 2009, 11:23
you cannot... first of all dont think that the file has the same layout on disk as you see it in notepad... there is no way to tell the file pointer to go directly to a certain line if all the lines are of variable lengths. what you can do is to read the whole file in a QStringList and then modify the QStringList and write back the whole stringlist