I want to read from a text file like simple C++'s fgetc but with QT QTextStream where I tried readall method but it skip the last characther which probably is a break.
Asked
Active
Viewed 3,533 times
1 Answers
1
You can use read method and set max number of characters for reading.
QString oneChar = stream.read(1);
or can use overload operator >> for QChar. Something like this
QChar oneChar = '';
stream >> oneChar;

DvoryankinEvgeny
- 128
- 1
- 8
-
and how can I get the size of the file to know when to stop or is there an EOF possibility? – user3540983 Mar 10 '15 at 14:50
-
1@user3540983 you can do it in while loop while (!stream.atEnd()) – DvoryankinEvgeny Mar 10 '15 at 14:53
-
Moreover you can use a for loop with your QString and do for(QChar mychar = mystring.begin() ; mychar != mystring.end() ; ++char) { qDebug() << *mychar; } and you sould see all your string char by char. – Gabrielle de Grimouard Mar 10 '15 at 15:06