For Qt Console apps, I have found it best to do the following:

1. Create a class with a void public slot that represents your main thread (or only thread). The slot should always exit with something like this:
Qt Code:
  1. QCoreApplication::exit(#); // Where # is the exit code
  2. return;
To copy to clipboard, switch view to plain text mode 
2. Use a one shot timer in the main function to call the slot.

So your main function would look like this:
Qt Code:
  1. #include <QTimer>
  2. int main(int argc, char *argv[])
  3. {
  4. QCoreApplication a(argc, argv);
  5. Sasaja sasaja;
  6. QTimer::singleShot(0, &sasaja, SLOT(DoWork()));
  7. return a.exec();
  8. }
To copy to clipboard, switch view to plain text mode 

Karl