Terminating a console app
I have a small console app that will do some post install file & text proccessing. I need it to be self terminating & I need it to NOT show a console while running. I tried a.quit() & a.exit() to terminate, but neither one worked. I'm not sure how to supress the console window. The app will run on Win.
Any help is appreciated.
Thanx,
Ed
Code:
#include <QTextStream>
#include <QString>
#include <QFile>
int main(int argc, char *argv[])
{
QFile file("fixPath.txt");
{
while (not in.atEnd())
{
str1 = in.readLine();
cout << str1 << endl;
}
file.close();
}
return a.exec();
}
Re: Terminating a console app
Suppressing the console window: Does in your Pro file do it for you? Of course, you have to have somewhere for your cout and cerr streams to go.
If you don't enter the event loop, i.e. don't call QCoreApplication::exec(), then the program just runs straight through to completion.
Re: Terminating a console app
Quote:
Originally Posted by
cejohnsonsr
I tried a.quit() & a.exit()
This is a common problem. You need to let the program enter the event loop.
To quit, you can use a timer with a singleshot for about 100ms and call the slot quit().
Re: Terminating a console app
Thank you for the answers. I'm learning & relearning a little at a time.
Ed