QCtrlSignals  1.0.0
A library to catch and handle windows and unix signals, in a cross platform manner
Public Types | Public Slots | Signals | Public Member Functions | Static Public Member Functions | Properties | Friends | List of all members
QCtrlSignalHandler Class Reference

A class to listen for "CTRL-Signals". More...

#include <qctrlsignalhandler.h>

Inheritance diagram for QCtrlSignalHandler:
QObject

Public Types

enum  CommonSignals { SigInt = SIGINT, SigTerm = SIGTERM }
 Common signals, that are available on all platforms. More...
 

Public Slots

void setAutoQuitActive (bool autoQuitActive)
 WRITE-Accessor for QCtrlSignalHandler::autoQuitActive.
 

Signals

void sigInt ()
 Shortcut signal for QCtrlSignalHandler::SigInt. More...
 
void sigTerm ()
 Shortcut signal for QCtrlSignalHandler::SigTerm. More...
 
void ctrlSignal (int signal)
 Will be emitted if a registered signal occures. More...
 
void autoQuitActiveChanged (bool autoQuitActive)
 NOTIFY-Accessor for QCtrlSignalHandler::autoQuitActive.
 

Public Member Functions

bool registerForSignal (int signal)
 Registers this handler for the given signal.
 
bool unregisterFromSignal (int signal)
 Unregisters this handler from the given signal.
 
bool isAutoQuitActive () const
 READ-Accessor for QCtrlSignalHandler::autoQuitActive.
 
- Public Member Functions inherited from QObject
 QObject (QObject *parent)
 
virtual bool event (QEvent *e)
 
virtual bool eventFilter (QObject *watched, QEvent *event)
 
virtual const QMetaObjectmetaObject () const
 
QString objectName () const
 
void setObjectName (const QString &name)
 
bool isWidgetType () const
 
bool isWindowType () const
 
bool signalsBlocked () const
 
bool blockSignals (bool block)
 
QThreadthread () const
 
void moveToThread (QThread *targetThread)
 
int startTimer (int interval, Qt::TimerType timerType)
 
void killTimer (int id)
 
findChild (const QString &name, Qt::FindChildOptions options) const
 
QList< T > findChildren (const QString &name, Qt::FindChildOptions options) const
 
QList< T > findChildren (const QRegExp &regExp, Qt::FindChildOptions options) const
 
QList< T > findChildren (const QRegularExpression &re, Qt::FindChildOptions options) const
 
const QObjectList & children () const
 
void setParent (QObject *parent)
 
void installEventFilter (QObject *filterObj)
 
void removeEventFilter (QObject *obj)
 
QMetaObject::Connection connect (const QObject *sender, const char *signal, const char *method, Qt::ConnectionType type) const
 
bool disconnect (const char *signal, const QObject *receiver, const char *method) const
 
bool disconnect (const QObject *receiver, const char *method) const
 
void dumpObjectTree ()
 
void dumpObjectInfo ()
 
bool setProperty (const char *name, const QVariant &value)
 
QVariant property (const char *name) const
 
QList< QByteArraydynamicPropertyNames () const
 
void destroyed (QObject *obj)
 
void objectNameChanged (const QString &objectName)
 
QObjectparent () const
 
bool inherits (const char *className) const
 
void deleteLater ()
 

Static Public Member Functions

static QCtrlSignalHandlerinstance ()
 Returns the singleton instance of the signal handler.
 
- Static Public Member Functions inherited from QObject
QString tr (const char *sourceText, const char *disambiguation, int n)
 
QString trUtf8 (const char *sourceText, const char *disambiguation, int n)
 
QMetaObject::Connection connect (const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type)
 
QMetaObject::Connection connect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &method, Qt::ConnectionType type)
 
QMetaObject::Connection connect (const QObject *sender, PointerToMemberFunction signal, const QObject *receiver, PointerToMemberFunction method, Qt::ConnectionType type)
 
QMetaObject::Connection connect (const QObject *sender, PointerToMemberFunction signal, Functor functor)
 
QMetaObject::Connection connect (const QObject *sender, PointerToMemberFunction signal, const QObject *context, Functor functor, Qt::ConnectionType type)
 
bool disconnect (const QObject *sender, const char *signal, const QObject *receiver, const char *method)
 
bool disconnect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &method)
 
bool disconnect (const QMetaObject::Connection &connection)
 
bool disconnect (const QObject *sender, PointerToMemberFunction signal, const QObject *receiver, PointerToMemberFunction method)
 

Properties

bool autoQuitActive
 Specifies, whether the handler should automatically handle signals that "quit" the app. More...
 
- Properties inherited from QObject
 objectName
 

Friends

class QCtrlSignalHandlerPrivate
 
class QCtrlSignalHandlerInstance
 

Additional Inherited Members

- Protected Member Functions inherited from QObject
QObjectsender () const
 
int senderSignalIndex () const
 
int receivers (const char *signal) const
 
bool isSignalConnected (const QMetaMethod &signal) const
 
virtual void timerEvent (QTimerEvent *event)
 
virtual void childEvent (QChildEvent *event)
 
virtual void customEvent (QEvent *event)
 
virtual void connectNotify (const QMetaMethod &signal)
 
virtual void disconnectNotify (const QMetaMethod &signal)
 

Detailed Description

A class to listen for "CTRL-Signals".

Those signals are the typical operating system signals, that can be send to applications. These are:

The QCtrlSignalHandler allows you to register for those signals in a cross-platform way. This means, some signals, that are present on all OSses, can be found in the QCtrlSignalHandler::CommonSignals enum. Others can be registered per platform.

The handler internally registers for those signals (Ctrl-Signals), and will emit the ctrlSignal() signal (Qt-Signal).

Note
Please read the main page, for more details about how to use them and limitation on the signal types that can be registered
See also
Mainpage

Definition at line 18 of file qctrlsignalhandler.h.

Member Enumeration Documentation

§ CommonSignals

Common signals, that are available on all platforms.

Note
These are not the only possible singals. However, these are the only ones you can find on all platforms. If you want to use other signals, simply use the defines available on the specific platform, like for example SIGQUIT on linux.
See also
QCtrlSignalHandler::registerForSignal, QCtrlSignalHandler::ctrlSignal, QCtrlSignalHandler::sigInt, QCtrlSignalHandler::sigTerm
Enumerator
SigInt 

Mapped to CTRL_C_EVENT on windows and SIGINT on unix.

SigTerm 

Mapped to CTRL_BREAK_EVENT on windows and SIGTERM on unix.

Definition at line 29 of file qctrlsignalhandler.h.

Member Function Documentation

§ ctrlSignal

QCtrlSignalHandler::ctrlSignal ( int  signal)
signal

Will be emitted if a registered signal occures.

Parameters
signalThe CTRL-Signal that was triggered

It is only emitted for manually registered signals, not for others. It is independent of the autoQuitActive property.

Note
This signal will be emitted for QCtrlSignalHandler::SigInt and QCtrlSignalHandler::SigTerm as well, even though they have their own signals. For those two, both signals will be emitted.
See also
QCtrlSignalHandler::CommonSignals, QCtrlSignalHandler::registerForSignal, QCtrlSignalHandler::sigInt, QCtrlSignalHandler::sigTerm

§ sigInt

QCtrlSignalHandler::sigInt ( )
signal

Shortcut signal for QCtrlSignalHandler::SigInt.

It is only emitted for manually registered signals, not for others. It is independent of the autoQuitActive property.

Note
This signal will be emitted alongsite QCtrlSignalHandler::ctrlSignal. You can catch SigInt on any of this two
See also
QCtrlSignalHandler::registerForSignal, QCtrlSignalHandler::ctrlSignal, QCtrlSignalHandler::sigTerm

§ sigTerm

QCtrlSignalHandler::sigTerm ( )
signal

Shortcut signal for QCtrlSignalHandler::SigTerm.

It is only emitted for manually registered signals, not for others. It is independent of the autoQuitActive property.

Note
This signal will be emitted alongsite QCtrlSignalHandler::ctrlSignal. You can catch SigInt on any of this two
See also
QCtrlSignalHandler::registerForSignal, QCtrlSignalHandler::ctrlSignal, QCtrlSignalHandler::sigInt

Property Documentation

§ autoQuitActive

QCtrlSignalHandler::autoQuitActive
readwrite

Specifies, whether the handler should automatically handle signals that "quit" the app.

Default: false

If auto quit is active, the handler will automatically register for "quit-like" signals. If they occur, it will handle them and automatically shut down the application by using QCoreApplication::quit.

Note
If you register for a "quit-like" signal manually, your own handling will be prefered, and ctrlSignal() gets emitted, instead of shutting down the app.
Accessors
READisAutoQuitActive()
WRITEsetAutoQuitActive()
NOTIFYautoQuitActiveChanged()
See also
QCtrlSignalHandler::ctrlSignal, QCtrlSignalHandler::registerForSignal

Definition at line 25 of file qctrlsignalhandler.h.


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