Hi to all,
I would pause the main thread for 2-3 sec and then exit from the application but I can not find a solution.

In my case when application starts a status dialog appears showing some result and then the main window is shown. There is a case where I would wait a couple of seconds ( to give to the user the time to read ) and then exit completely from the application. This is the code I wrote:

Qt Code:
  1. void CertiIrisApp::init() //CertiIrisApp is the main application derived class
  2. {
  3. start = new StartDlg(0); // start is a dialog showing some initialization results
  4. start->show();
  5. start->print(QString("> Welcome to CertiIris")); //print prints a message
  6. processEvents();
  7. start->print(QString("> Checking for Iris scanner..."));
  8. if (checkIrisScanner())
  9. {
  10. start->print(QString("> Correct Iris scanner connected."));
  11. processEvents();
  12. }
  13. else
  14. {
  15. QString msg = "> An incorrect iris scanner has been connected, contact author.";
  16. start->print(msg);
  17. processEvents();
  18. Sleep(1); // I would wait to give the time to read
  19. QCoreApplication::exit(1); //and then exit
  20. }
  21.  
  22. if ( connectToDB() == true )
  23. {
  24. QString str = "> " + QCoreApplication::applicationName() + " is successfully connected to the IrisServer.";
  25. start->print(str);
  26. processEvents();
  27. onLoadDBRecords();
  28. }
  29. else
  30. {
  31. QString str = "> " + QCoreApplication::applicationName() + " could not connected to the IrisServer.";
  32. start->print(str);
  33. processEvents();
  34. }
  35.  
  36. start->hide(); // hide the dialog
  37. delete start; // and delete it
  38. m_mainWnd->show(); // here I show the main window
  39. return;
  40. }
To copy to clipboard, switch view to plain text mode 
The problem of my code is that the program flow doesn't wait at the Sleep call and follow showing the next message.
Where is my mistake?

Regards,
Franco