You can do something like the following:
// first, we open the file
QFile file("outfile.txt");
file.open(QIODevice::WriteOnly);
// now that we have a file that allows us to write anything to it,
// we need an easy way to write out text to it
QTextStream qout(&file);
// I can write out a single ASCII character doing the following
qout << QChar((int)'\n');
// But when you're dealing with unicode, you have to be more careful
// about character sets and locales.
// I can now easily write out any string
QString text("Hello!");
qout << text;
// and when you're done, make sure to close the file
file.close();
See the documentation on QFile, QTextStream, QString, and QChar all of which is available on the qt documentation website.