Snaidy
26th August 2016, 04:42
Hi Guyz,
I am new to QT ,I am trying to work with file and manipulate the string from file,I don't know how I can do this,
I have an txt file containing below data,
Target1 :ABCDEF $
Target1 :GHIJ %
Target2 : KLMNO$
Target2 : PQRS%
Target3: TUV
Target4: XYZ
I want to take ABCDEF , GHIJ ,KLMNO , PQRS , TUV , XYZ data alone.
In normal C/C++ ,we use array, string functions and compare .... .I hope in QT also,there is a possibility but I dont know how to take advantage of the pre-defined methods in QT .
for reading file I wrote this,
void MainWindow::readFile()
{
QFile file("/home/renupapa/Desktop/QT/Testfile.txt");
if(!file.open(QFile::ReadOnly|QFile::Text))
{
QMessageBox::warning(this,"Title","Error File not opened !!!!! ");
}
QTextStream in(&file);
QString text=in.readAll();
ui->plainTextEdit->setPlainText(text);
file.close();
}
1. Can any one help me how I can take the specific data from the file and manipulate it ?
2. Also where I can find clear guide on these QT methods with examples ?
Thanks in Advance,
E.Karthick
I am new to QT ,I am trying to work with file and manipulate the string from file,I don't know how I can do this,
I have an txt file containing below data,
Target1 :ABCDEF $
Target1 :GHIJ %
Target2 : KLMNO$
Target2 : PQRS%
Target3: TUV
Target4: XYZ
I want to take ABCDEF , GHIJ ,KLMNO , PQRS , TUV , XYZ data alone.
In normal C/C++ ,we use array, string functions and compare .... .I hope in QT also,there is a possibility but I dont know how to take advantage of the pre-defined methods in QT .
for reading file I wrote this,
void MainWindow::readFile()
{
QFile file("/home/renupapa/Desktop/QT/Testfile.txt");
if(!file.open(QFile::ReadOnly|QFile::Text))
{
QMessageBox::warning(this,"Title","Error File not opened !!!!! ");
}
QTextStream in(&file);
QString text=in.readAll();
ui->plainTextEdit->setPlainText(text);
file.close();
}
1. Can any one help me how I can take the specific data from the file and manipulate it ?
2. Also where I can find clear guide on these QT methods with examples ?
Thanks in Advance,
E.Karthick