本文介紹了Qt可以使用cin嗎?的處理方法,對(duì)大家解決問(wèn)題具有一定的參考價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)吧!
問(wèn)題描述
是否可以在 Qt 中使用 cin
?我可以使用 cout
但找不到如何在 Qt 控制臺(tái)應(yīng)用程序中使用 cin
的示例.
Is it possible to use cin
in Qt? I can use cout
but cannot find examples of how to use cin
within a Qt console application.
推薦答案
我測(cè)試了 Kaleb Pederson 的回答,并找到了比他提出的解決方案更簡(jiǎn)潔的方法(盡管我必須感謝他為我指明了正確的方向):
I tested out Kaleb Pederson's answer, and found a more consise way than the solution he presented (though I have to thank him for pointing me to the right direction):
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.
換句話說(shuō),您并不真正需要 QFile 作為您的中間人.
In other words, you don't really need QFile as your middleman.
這篇關(guān)于Qt可以使用cin嗎?的文章就介紹到這了,希望我們推薦的答案對(duì)大家有所幫助,也希望大家多多支持html5模板網(wǎng)!
【網(wǎng)站聲明】本站部分內(nèi)容來(lái)源于互聯(lián)網(wǎng),旨在幫助大家更快的解決問(wèn)題,如果有圖片或者內(nèi)容侵犯了您的權(quán)益,請(qǐng)聯(lián)系我們刪除處理,感謝您的支持!