I’m trying to use QTextStream to output to stdout, but nothing happens unless I enter a character. I have tried including cstdlib, this did not work either.
Note: I tried removing all references to my stdin QTextStream and output worked fine.
#include <QTextStream>
QTextStream out(stdout);
out << "Please enter login username and password\n";
QTextStream in(stdin);
out << "username:";
QString username = in.readLine();
out << "password:";
QString password = in.readLine();
You have to manually flush the buffer after each time you push something in the stream:
Alternatively, appending
<< endlalso works.