I'm trying to read from a file using this code:
const char *imageFile = repertoire_Hu.filePath(img_files_Hu[i]).toStdString().c_str();
QFile f(imageFile);
QTextStream out(&f);
float tab2[7];
int q = 0;
if(f.open(QIODevice::ReadOnly | QIODevice::Text))
{
while(!out.atEnd())
{
QString line = out.readLine();
tab2[q] = line.toFloat();
q ++;
}
}
f.close();
This is the content of my file
-1557.35 0.659662 -2.65505 5.43287e-23 5.4945e-34 -5.65088e-35 -1.35751e+38
But when I plot the values after reading the file I get wrong values (completely different from the values in the file when I compare them) and sometimes the file can't be opened and most of the time it doesn't read all the values in the file.
I guess I'm doing something wrong somewhere but I can't figure it.
I don't spot anything immediately wrong, so you need to do more debugging. This should help you find the problem: