There a many ways to achieve this. Here is one that uses QTextStream to worry about finding the white space delimiter:
#include <QtCore>
#include <QDebug>
int main(int argc, char* argv[])
{
QFile in
("/tmp/data.txt");
while (!s.atEnd()) {
s >> dummy; // ignore the first field
s >> value;
dummy = s.readLine(); // ignore the remainder of the line
qDebug() << value;
}
in.close();
}
}
#include <QtCore>
#include <QDebug>
int main(int argc, char* argv[])
{
QCoreApplication app(argc, argv);
QFile in("/tmp/data.txt");
if (in.open(QIODevice::ReadOnly)) {
QTextStream s(&in);
while (!s.atEnd()) {
QString dummy, value;
s >> dummy; // ignore the first field
s >> value;
dummy = s.readLine(); // ignore the remainder of the line
qDebug() << value;
}
in.close();
}
}
To copy to clipboard, switch view to plain text mode
No matter what approach you take you have to read the entire line in order to get to the next line.
Bookmarks