Reading numbers from a file
Solved
Qt Creator and other tools
-
I have a .txt document with 2 column numbers like this:
5.4 2.1
2.4 2.5
3.4 6.4
... ...
and so on.How can i store them in QVectors x,y using Qfile and QTextStream?
current code:
QFile file(file_name); if(!file.open(QIODevice::ReadOnly)) { qDebug() << "didnt open"; } QTextStream stream(&file); QVector<float> x,y; while(!stream.atEnd()) { QString line = stream.readLine(); } for(int i=0;i<x.size();i++) { file >> x[i] >> " " >> y[i]; }
thank you and have a good day!