Important: Please read the Qt Code of Conduct -

Get the Error type which cause the application crash

  • I am using Qt 4.8. I used qInstallMsgHandler() and i handle critical and fatal error like

     void myMessageOutput(QtMsgType type, const char *msg)
        switch (type) {
        case QtCriticalMsg:
           //restarts application
        case QtFatalMsg:
            // restarts application

    It works properly when i get fatal or critical. But some time my application get crash without giving the critical or fatal msg. Is ther any way to get what type of error my application getting crash.

  • @Shahina

    You are only catching the errors listed in here. Basically you have to call those functions listed on the right and your application will end up in your message handler with an appropriate error code. Therefore, you need to know where in your application critical conditions are being encountered. Unfortunately, it does not support a crystal ball functionality covering all possible errors.

  • Ok its clear now. But i cannot encounters the critical condition in my application beacuse i am using a third party dll. Some times it get crash from dll only. I dont have source. Is there any way to handle crash in my application itself.

  • @Shahina

    You would need to check the documentation of the dll. Possibly there are some measures implemented for catching possible error conditions.

  • if your library is throwing an exception it's just up to you to catch it:

    if it's just crashing because of a segmentation fault or similar there are libraries to convert them into exceptions:

  • Thanks for the links. It helped me. Is there any way to have gloabl try and catch block in qt ?

  • well, if you start the try block in the main function then it should catch any unhanded exception

Log in to reply