View Full Version : Find function in Qt ?
Hi folks,
Is there any function in Qt to find a string in a file.
Or any other solution to get a needed text instead of reading line by line.
Thanks,
-;)
wysota
8th May 2006, 17:21
QFile f("somefile");
f.open(QIODevice::ReadOnly);
QString data = f.readAll();
int i = data.indexOf("Find me");
Thank you very much wysota.
Could you tell me how to remove a particular line from the file,
or replace that line by some other line, completely.
Thanks
-;)
how to remove a particular line from the file, or replace that line by some other line, completely.
Then it's probably easiest to simply read line by line, for example append all read (and possibly modified/replaced) lines to a string(list) and then write it back to the file. You cannot remove data from the middle of a file. You have to read it all, modify, and then re-write the file.
Powered by vBulletin® Version 4.2.5 Copyright © 2024 vBulletin Solutions Inc. All rights reserved.