How can I read a text file line by line in Qt?
I'm looking for the Qt equivalent to:
std::ifstream infile; std::string line; while (std::getline(infile, line)) { ... }
Use this code:
QFile inputFile(fileName); if (inputFile.open(QIODevice::ReadOnly)) { QTextStream in(&inputFile); while (!in.atEnd()) { QString line = in.readLine(); ... } inputFile.close(); }
1.4m articles
1.4m replys
5 comments
57.0k users