#include#include int main() { QFile file("example.txt"); if(file.open(QIODevice::ReadOnly | QIODevice::Text)) { while(!file.atEnd()) { qDebug() << file.readLine(); } file.close(); } return 0; }
#includeThis code opens a file named "example.txt" in write-only text mode and appends a new line of text to the end of the file. The atEnd() function is not used in this example. Package Library: Qt Core Library#include #include int main() { QFile file("example.txt"); if(file.open(QIODevice::WriteOnly | QIODevice::Append | QIODevice::Text)) { QTextStream out(&file); out << "This is a new line.\n"; file.close(); } return 0; }