废话不说直接上代码
1.
QString displayString;
QFile file("/home/alvin/text.txt");
if(!file.open(QIODevice::ReadOnly | QIODevice::Text))
{
qDebug()<
}
while(!file.atEnd())
{
QByteArray line = file.readLine();
QString str(line);
qDebug()<< str;
displayString.append(str);
}
ui->textEdit->clear();
ui->textEdit->setPlainText(displayString);
2.
QString displayString;
QFile file("/home/alvin/text.txt");
if (!file.open(QIODevice::ReadOnly | QIODevice::Text))
return;
QTextStream in(&file);
QString line = in.readLine();
while (!line.isNull())
{
// process_line(line);
line = in.readLin