Hello every one i am stuck at a small problem. I have a text file with some data which i am reading from my Qt program. I put the read text string into a QString container. I am trying to split the string after every blank space and want to put it in a array
and access any particular data position with its index number.
QFile file("C:/thermaldata.txt");
if ( file.open(IO_ReadOnly | IO_Translate))
{
line.append(stream.readLine());
file.close();
}
list = line.split(" "); // trying to split the string after every blank space
}
QFile file("C:/thermaldata.txt");
QString line;
if ( file.open(IO_ReadOnly | IO_Translate))
{
QTextStream t( &file );
QTextStream stream( &file );
line.append(stream.readLine());
file.close();
}
QStringList list;
list = line.split(" "); // trying to split the string after every blank space
}
To copy to clipboard, switch view to plain text mode
I wanted to put each word in the text string in an array something like
list.at(0) should have 5/3/2011
list.at(1) should have 11:47:24
so that i can access any word according to their position.
This is the text string i read from the text file.
("5/3/2011 11:47:24 AM 1.33E+3 853 1.33E+3 868 P235.529 235.864 27.014 26.505 27.108 26.695 26.806 26.602 26.852 236.065 30.987 27.160 27.969 27.222 26.199 30.690 33.263 26.576 26.518 236.360 236.626 26.590")
("5/3/2011 11:47:24 AM 1.33E+3 853 1.33E+3 868 P235.529 235.864 27.014 26.505 27.108 26.695 26.806 26.602 26.852 236.065 30.987 27.160 27.969 27.222 26.199 30.690 33.263 26.576 26.518 236.360 236.626 26.590")
To copy to clipboard, switch view to plain text mode
how should i go about doing this.. ?? i tried a few things but couldn't get what i wanted.
Thank you
Bookmarks