在 Qt 中可以使用 cin
吗?我可以使用 cout
但找不到有关如何在 Qt 控制台应用程序中使用 cin
的示例。
最佳答案
我测试了Kaleb Pederson的答案,并找到了比他提出的解决方案更简洁的方法(尽管我必须感谢他为我指明了正确的方向):
QTextStream qtin(stdin);
QString line = qtin.readLine(); // This is how you read the entire line
QString word;
qtin >> word; // This is how you read a word (separated by space) at a time.
换句话说,你并不真的需要 QFile 作为你的中间人。
关于c++ - Qt 可以使用 cin 吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2321880/