nbetcher
23rd March 2009, 03:57
Hello,
I am developing a Qt console application and have run into a snag: the application does not quit when told to using 'exit(1);' The class is constructed with QCoreApplication as the parent and within the constructor I parse the command-line parameters passed to the application. If there are no parameters passed or '-h' or '--help' is passed then the application prints the usage help, then quits. Unfortunately the program does not quit after printing the help, then being instructed to exit().
When it prints the help it calls a function to automate that task, and in that function a QTextStream is created against stdout. The help is printed using lines such as this (where 'console' is the QTextStream(stdout) ):
console << "Exit status is 0 if OK, otherwise failure." << endl;
Once the help is printed the function simply ends. It then returns back into the constructor's loop to finish construction and exit(1) is called, but the application doesn't exit. I've also tried 'qApp->exit(1)' to make sure that no funny-business was going on.
Also, the main.cpp file DOES contain 'return a.exec()' where 'a' is the QCoreApplication class constructed.
What is the reason the program is not exiting? Can exit() not be called in the constructor?
Thanks,
Nick Betcher, CPhT
I am developing a Qt console application and have run into a snag: the application does not quit when told to using 'exit(1);' The class is constructed with QCoreApplication as the parent and within the constructor I parse the command-line parameters passed to the application. If there are no parameters passed or '-h' or '--help' is passed then the application prints the usage help, then quits. Unfortunately the program does not quit after printing the help, then being instructed to exit().
When it prints the help it calls a function to automate that task, and in that function a QTextStream is created against stdout. The help is printed using lines such as this (where 'console' is the QTextStream(stdout) ):
console << "Exit status is 0 if OK, otherwise failure." << endl;
Once the help is printed the function simply ends. It then returns back into the constructor's loop to finish construction and exit(1) is called, but the application doesn't exit. I've also tried 'qApp->exit(1)' to make sure that no funny-business was going on.
Also, the main.cpp file DOES contain 'return a.exec()' where 'a' is the QCoreApplication class constructed.
What is the reason the program is not exiting? Can exit() not be called in the constructor?
Thanks,
Nick Betcher, CPhT