QT Windows Exception Logging Technique

Published: 25 May 2024
Last Updated: 2 June 2024


Background

QT Windows C++ Applications do not have a specific Windows Exception handler.


In MFC, there is a CodeProject project XCrashReport.


In QT, there isn't a specific SEH (Structured Exception Handler) so you need to add this manually.


QT Windows SEH Handler

In main.cpp file, before QT starts, add the following lines


#ifdef _WINDOWS
// This code is specific to Windows platform
#define NOMINMAX
#include <windows.h>
#undef NOMINMAX


LONG WINAPI unhandled_handler(struct _EXCEPTION_POINTERS *apExceptionInfo);
{
    // Create your SEH 
    create_minidump(apExceptionInfo);
    return EXCEPTION_CONTINUE_SEARCH;
}
#endif

int main(int argc, char *argv[])
{
#ifdef _WINDOWS
    SetUnhandledExceptionFilter(unhandled_handler);
#endif
    QApplication app(argc, argv);
    return app.exec();
}

The above code, paired with an on-line bug tracker and CI/CD environment, allows for fast bug triage for QT applications.

Polywick Studio provides affordable,

efficient, quality app development

services for global companies.


© Polywick Studio 2018-2024.