Medical Imaging Interaction Toolkit  2026.06.00
Medical Imaging Interaction Toolkit
QmitkSingleApplication Class Reference

A single-instance application with optional exception-safe event dispatching. More...

#include <QmitkSingleApplication.h>

Inheritance diagram for QmitkSingleApplication:
Collaboration diagram for QmitkSingleApplication:

Public Member Functions

 QmitkSingleApplication (int &argc, char **argv, bool safeMode=true)
 Construct a QmitkSingleApplication. More...
 
bool notify (QObject *receiver, QEvent *event) override
 Reimplements QtSingleApplication::notify() to catch unhandled exceptions. More...
 
void setSafeMode (bool safeMode)
 Enable or disable safe mode. More...
 
bool getSafeMode () const
 Query whether safe mode is currently enabled. More...
 

Detailed Description

A single-instance application with optional exception-safe event dispatching.

This class extends QtSingleApplication (which ensures only one instance of the application runs at a time) with the same safe-mode behavior as QmitkSafeApplication. When safe mode is enabled, unhandled exceptions thrown during Qt event processing are caught and reported to the user instead of crashing the application.

This class is used by mitk::BaseApplication when single-instance mode is requested.

See also
QmitkSafeApplication, mitk::BaseApplication

Definition at line 34 of file QmitkSingleApplication.h.

Constructor & Destructor Documentation

◆ QmitkSingleApplication()

QmitkSingleApplication::QmitkSingleApplication ( int &  argc,
char **  argv,
bool  safeMode = true 
)

Construct a QmitkSingleApplication.

Parameters
[in,out]argcReference to the application argument count (passed to QtSingleApplication).
[in]argvArray of command line argument strings (passed to QtSingleApplication).
[in]safeModeIf true, exception-safe event dispatching is enabled. Defaults to true.

Member Function Documentation

◆ getSafeMode()

bool QmitkSingleApplication::getSafeMode ( ) const

Query whether safe mode is currently enabled.

Returns
true if safe mode is enabled; false otherwise.

◆ notify()

bool QmitkSingleApplication::notify ( QObject *  receiver,
QEvent *  event 
)
override

Reimplements QtSingleApplication::notify() to catch unhandled exceptions.

When safe mode is enabled, exceptions thrown during event processing are caught and an error message dialog is displayed. When safe mode is disabled, this method delegates directly to QtSingleApplication::notify().

Parameters
[in]receiverThe target QObject that should receive the event.
[in]eventThe QEvent to be delivered to the receiver.
Returns
true if the event was recognized and processed by the receiver; false otherwise.

◆ setSafeMode()

void QmitkSingleApplication::setSafeMode ( bool  safeMode)

Enable or disable safe mode.

Parameters
[in]safeModeIf true, exception-catching event dispatching is enabled.

The documentation for this class was generated from the following file: