QTextStream

最后更新于:2022-04-02 02:12:45

[TOC] ## 实例 实例一: **赋值** ``` QString strOut; QTextStream streamOut(&strOut); //打印多种进制数字 streamOut<<800; ``` 实例二: 赋值给变量 ``` QString strIn = QObject::tr("800 abcd 123.789999"); QTextStream streamIn(&strIn); int numDec = 0; QString strSub; double dblReal = 0.0; //输入到变量里 streamIn>>numDec>>strSub>>dblReal; ``` 实例三: 读取文件 ``` QFile file("D:\\code\\hello_qt\\http\\mainwindow.cpp"); file.open(QIODevice::ReadOnly); QTextStream stream(&file); while (!stream.atEnd()) { qDebug()<>nCode; if( 9 == nCode ) { tsOut<< a.tr("程序结束。")< ';