Search code examples
qtqt4

Newline character into textfile using QFile


i want to put a newline into a txt file, i tried with many alternative with so many help from this forum but i am getting always unknown character always. Please help

for (int i = 0; i < fileDet.size(); i++) {
  qDebug() << "Name directory" << fileDet.at(i);
  QFile data("output.txt");
  if (data.open(QFile::Append)) {
    QTextStream out(&data);
    out << fileDet.at(i);  //<<'\n';
    out << QChar((int)'\n');
  }
  data.close();
}

Solution

  • Try out << endl;