Идея от @thuga и @ drescherjm
QString TXT="l1\nl2\nl3\nl4", Line;
QTextStream stream(&TXT);
while (stream.readLineInto(&Line)) {
std::cout <<Line.toStdString() << std::endl;
}
//Set the device to pos 0
stream.seek(0);
Вывод:
l1
l2
l3
l4
QString TXT="l1\nl2\nl3\nl4";
QStringList Lines = TXT.split('\n');
for (int i = 0; i < Lines.size(); i++) {
std::cout <<Lines[i].toStdString() << std::endl;
}
Вывод:
l1
l2
l3
l4