Qt讀寫標準輸入/輸出流
阿新 • • 發佈:2019-01-29
答案:QFile和QTextSream
QTextStream我沒嘗試過,可跳轉:
https://blog.csdn.net/haha_mingg/article/details/6884883
QFile可行,具體例項,可見https://blog.csdn.net/daizhiyan1/article/details/80596583裡面對標準輸入輸出流的讀寫。
讀取標準輸入輸出流的問題困擾了我挺久的..專門列出來,方便需要的人查詢吧,歡迎交流。
bool QFile::open ( int fd, OpenMode mode ) This is an overloaded function. Opens the existing file descriptor fd in the given mode. Returns true if successful; otherwise returns false. When a QFile is opened using this function, close() does not actually close the file. The QFile that is opened using this function is automatically set to be in raw mode; this means that the file input/output functions are slow. If you run into performance issues, you should try to use one of the other open functions. Warning: If fd is not a regular file, e.g, it is 0 (stdin), 1 (stdout), or 2 (stderr), you may not be able to seek(). In those cases, size() returns 0. See QIODevice::isSequential() for more information. Warning: For Windows CE you may not be able to call seek(), setSize(), fileTime(). size() returns 0. Warning: Since this function opens the file without specifying the file name, you cannot use this QFile with a QFileInfo.