[英]QTextStream is not outputting anything, what could I be doing wrong?
我正在嘗試使用QTextStream輸出到stdout,但除非我輸入一個字符,否則沒有任何反應。 我試過包括cstdlib,這也沒用。
注意:我嘗試刪除對我的stdin QTextStream的所有引用,輸出工作正常。
#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();
每次在流中推送內容后,您必須手動刷新緩沖區:
QTextStream out(stdout);
out << "Please enter login username and password\n";
out.flush();
QTextStream in(stdin);
out << "username:";
out.flush();
QString username = in.readLine();
out << "password:";
out.flush();
QString password = in.readLine();
或者,附加<< endl
也可以。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.