PDA

View Full Version : Find and replace a string in file using QFile class in QT



mania
6th December 2013, 06:45
Hi all,

I am able to read data from the file and stored it in QString , now i want to find and replace a string in that file.
Can one help me and give a solution.



Thanks in advance.

ChrisW67
6th December 2013, 06:52
There is no magic bullet function to "find and replace a string in that file". QString::replace() seems obvious enough though.

There is a small thing in every copy of Qt called Assistant. Assistant contains overview, reference documentation and examples you might find informative.

scarecr0w132
6th December 2013, 08:57
There is no magic bullet function to "find and replace a string in that file". QString::replace() seems obvious enough though.

There is a small thing in every copy of Qt called Assistant. Assistant contains overview, reference documentation and examples you might find informative.
Yes, we are spoiled with QT documentation

mania
6th December 2013, 12:11
Hi all,

I have append my scratch code below:

QFile file("/root/vodo");
if (!file.open(QIODevice::ReadWrite| QIODevice::Text))
return;

QTextStream in(&file);
QString line = in.readAll();
qDebug()<<"Text file Data..>>"<<line;
file.close();

Output of the above code:

Information datum
File exist

I want to replace " datum " to "data"

Kindly any one help me.

Thanks in advance.

ChrisW67
6th December 2013, 20:12
You already have the answer. Try to help yourself.

mania
16th December 2013, 11:28
Hi all,

Thanks for your support and encourage me , i have solved the issue of replacing string in file .Tanks to all

Now i want to create qrcode of converting string to qrcode and convert image to qrcode

Can any one help me

Thanks in advance.

ChrisW67
17th December 2013, 00:02
Can any one help me
Yes, start by not double posting (http://www.qtcentre.org/threads/57293-QR-Code).. then you only have to look in one place for an answer..

mania
2nd January 2014, 08:08
Hi,

I have posted in separately for QRcode related , but i'm not get the solution that's why i have double posting .


Thanks in advance.

anda_skoa
2nd January 2014, 14:44
I have posted in separately for QRcode related , but i'm not get the solution that's why i have double posting .


Double posting does nothing to help in that case.
Actually it is the opposite of helpful because double postings are extremely annoying.They require people to read the same things multiple times, taking away their time to read a really new question. So the effect is that they henceforth ignore all postings of known double posters.

That is if they are lucky. If the annoyed person is a moderator or admin the double poster will likely get warned, on repetition of the offence bannded.

In other words: double posting hurts your cause.

Cheers,
_