PDA

View Full Version : how i find and replace the text in text file through QT 4 interface



hasnatzaidi
30th April 2009, 05:37
i am using QT 4 ..and now i want to change in text file which stored in that folder.
for example "a.txt"......i wana find text and replace text when i push "ENTER" button.
plz reply i m in trouble

e8johan
30th April 2009, 08:01
I'm not 100% sure of what you mean. Do you want to open a file, replace some text in it and then write it back to the same file?

In that case, I suggest that you start with a QFile, read its contents into RAM (I assume that the file is reasonably sized) using readAll, do the replacement (QString::replace might work), and then re-open the file for writing and write it all back there.

hasnatzaidi
3rd May 2009, 08:38
thx 4 rply..............actually i mean to say that i have created interface like that

enter IP Address:.............................
enter host name:...........................
:SAVE BUTTON:

when we click it then these two fields save in file, which is stored in file...
this file is same like that fields such as...
IP Address=_._._._
Host name=_____
etc....

So i want to code for "Find" record and replace record through interface.

plz reply

e8johan
3rd May 2009, 08:58
You could use a QSettings object.