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;
}