简体   繁体   中英

How can I read character by character from a text file in QT C++?

我想从像简单C ++的fgetc这样的文本文件中读取内容,但要使用QT QTextStream尝试读取所有方法,但它会跳过最后一个字符,这可能是一个突破。

You can use read method and set max number of characters for reading.

    QString oneChar = stream.read(1);

or can use overload operator >> for QChar. Something like this

    QChar oneChar = '';
    stream >> oneChar;

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM