You peek from QIODevice
, but then you read from QTextStream
, that's why peek works only once. Try this:
while (!s.atEnd()) {
++i;
qDebug() << "Peek" << i << s.device()->peek(3);
QByteArray v = s.device()->readLine ();
qDebug() << "Word" << i << v;
}
Unfortunately, QIODevice
does not support reading single words, so you would have to do it yourself with a combination of peak and read.