Here is an example of a header I sometimes use in text files.....the first part of the code allows the user to select where to place the file and what name they want to give the file.
tr("Error Report (*.txt)"));
{
out << "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\r\n";
out << "~ Title of whatever your outputting...\r\n";
out <<
"~ Date: " <<tr
("%1 \r\n").
arg(QDateTime::currentDateTime().
toString());
out << "~ File Name: "<< tr("%1 \r\n").arg(yourFileName);
out << "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\r\n";
out << "\r\n";
txtF.close();
QString txtFile = QFileDialog::getSaveFileName(this, tr("Save Error Report"), ":",
tr("Error Report (*.txt)"));
QFile txtF(txtFile);
if(txtF.open(QFile::WriteOnly | QFile::Truncate))
{
QTextStream out(&txtF);
out << "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\r\n";
out << "~ Title of whatever your outputting...\r\n";
out << "~ Date: " <<tr("%1 \r\n").arg(QDateTime::currentDateTime().toString());
out << "~ File Name: "<< tr("%1 \r\n").arg(yourFileName);
out << "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\r\n";
out << "\r\n";
txtF.close();
To copy to clipboard, switch view to plain text mode
Try that and see if it helps you any!
Bookmarks