Important: Please read the Qt Code of Conduct -

How should I properly terminate a program after an exception?

  • Say, if I have an exception where recovery is not possible, how should I properly terminate the program? There are qFatal, QApplication::quit(), exit(EXIT_FAILURE) and so on. What should I use in my case?

  • Lifetime Qt Champion


    Without knowing your current use case it's difficult to tell. What do you mean by "recovery is not possible" ? Is it something like a device that has been removed ? Or is it something that would make the application crash ? In the second case qFatal is the way to go because your application would crash anyway. Using qFatal you can give a useful information to your user.

Log in to reply