sydjung
11th October 2011, 09:07
Hi guys,
I have a question regarding get data from readLine() function.
Currently, my function read line by line from a text file.
Each line has two numbers with a space between them. (eg. 234.23 454.32).
Is there a way to get those two number separately?
Here is my code.
bool getInfo(QString fileName) {
QFile myFile(fileName);
if(!myFile.exists()){
qDebug()<<"The file"<<myFile.fileName()<<"does not exist.";
return false;
}
if(!myFile.open(QIODevice::ReadOnly | QIODevice::Text)){
qFatal("Could not open the file");
return false;
}
QTextStream st(&myFile);
while (!st.atEnd()){
QString text;
text=st.readLine();
qDebug() << text;
In the code each line is stored in text and displayed by qDebug(). I would like to also display each numbers in a line sperately like x value is 234.23 and y value is 454.32.
Any idea?
I have a question regarding get data from readLine() function.
Currently, my function read line by line from a text file.
Each line has two numbers with a space between them. (eg. 234.23 454.32).
Is there a way to get those two number separately?
Here is my code.
bool getInfo(QString fileName) {
QFile myFile(fileName);
if(!myFile.exists()){
qDebug()<<"The file"<<myFile.fileName()<<"does not exist.";
return false;
}
if(!myFile.open(QIODevice::ReadOnly | QIODevice::Text)){
qFatal("Could not open the file");
return false;
}
QTextStream st(&myFile);
while (!st.atEnd()){
QString text;
text=st.readLine();
qDebug() << text;
In the code each line is stored in text and displayed by qDebug(). I would like to also display each numbers in a line sperately like x value is 234.23 and y value is 454.32.
Any idea?