What is the point of lines 9 and 10 in the above code?
If you are on windows it might be smart to pass the QIODevice::Text flag while opening the file. Without it you probably get \x0A instead of \x0D\x0A for end of line.
This works fine for me:
#include <QtCore>
int main(){
f.
open(QFile::WriteOnly|QFile
::Truncate|QFile
::Text);
list << "abc" << "def" << "ghi";
str << s << endl;
}
return 0;
}
#include <QtCore>
int main(){
QFile f("res.txt");
f.open(QFile::WriteOnly|QFile::Truncate|QFile::Text);
QTextStream str(&f);
QStringList list;
list << "abc" << "def" << "ghi";
foreach(const QString &s, list){
str << s << endl;
}
return 0;
}
To copy to clipboard, switch view to plain text mode
Bookmarks