Qt-读取文件内容
作者:互联网
1. 利用QFile和QTextStream
vector<QString> Dialog::ReadFile(const QString &fileName)
{
vector<QString> contents;
QFile file(fileName);
if(file.open(QIODevice::ReadOnly | QIODevice::Text))
{
QTextStream textStream(&file);
while (!textStream.atEnd())
{
contents.push_back(textStream.readLine());
}
}
return contents;
}
标签:文件,Qt,QFile,fileName,file,textStream,QTextStream,contents,读取 来源: https://www.cnblogs.com/xiang-L/p/15931991.html