I may have asked the question badly. What you showed me will use the QTextStream object to ouptput to stdout (the monitor). What I want is for the output to go to a file.
Here is what I have. I think you'll be able to see what I want to do.
#include <QtCore/QCoreApplication>
#include <QTextStream>
#include <QString>
#include <QFile>
QTextStream cerr(stderr,
QIODevice::WriteOnly);
//I haven't figured out how to use them to output to a file
int main(int argc, char *argv[])
{
QFile inFile
("fixPath.txt"), outFile
("fixPath2.txt");
{
while (not inFileStream.atEnd())
{
str1 = inFileStream.readLine();
if (str1.contains(str2))
{
str1.remove(str2);
outFileStream << str1 << endl;//here is where I'd like to be able to use cout
} //to write to the file instead of the screen
else
outFileStream << str1 << endl;
}
inFile.close();
outFile.close();
}
//return a.exec();
}
#include <QtCore/QCoreApplication>
#include <QTextStream>
#include <QString>
#include <QFile>
QTextStream cout(stdout, QIODevice::WriteOnly); //Same example showed what these are for.
QTextStream cerr(stderr, QIODevice::WriteOnly); //I haven't figured out how to use them to output to a file
int main(int argc, char *argv[])
{
QCoreApplication a(argc, argv);
QString str1, str2(" fixPath");
QFile inFile("fixPath.txt"), outFile("fixPath2.txt");
if(inFile.open(QIODevice::ReadOnly) && outFile.open(QIODevice::WriteOnly))
{
QTextStream inFileStream(&inFile);
QTextStream outFileStream(&outFile);
while (not inFileStream.atEnd())
{
str1 = inFileStream.readLine();
if (str1.contains(str2))
{
str1.remove(str2);
outFileStream << str1 << endl;//here is where I'd like to be able to use cout
} //to write to the file instead of the screen
else
outFileStream << str1 << endl;
}
inFile.close();
outFile.close();
}
//return a.exec();
}
To copy to clipboard, switch view to plain text mode
Bookmarks