I am trying to read values from a text file using the Qt code given below.
int ReadFromFile(QString fileName)
{
QFile file(fileName);
if (!file.open(QIODevice::ReadOnly | QIODevice::Text))
return 1;
QTextStream in(&file);
while (!in.atEnd())
{
QString line = in.readLine(1); //read one line at a time
QStringList lstLine = line.split(",");
}
file.close();
return 0;
}
The content of the text file is as follows:
1,0.173648178
2,0.342020143
3,0.5
4,0.64278761
5,0.766044443
6,0.866025404
However readLine always returns one character at a time but my intention is to read one line at a time and to split each line to get the individual comma seperated values.
Am I missing something basic here?