CopperSpice API  1.9.1
QAbstractEventDispatcher Class Referenceabstract

Interface to manage the event queue. More...

Inheritance diagram for QAbstractEventDispatcher:
QObject

Public Signals

void aboutToBlock ()
 
void awake ()
 
- Public Signals inherited from QObject
void destroyed (QObject *obj=nullptr)
 
void objectNameChanged (const QString &objectName)
 

Public Methods

 QAbstractEventDispatcher (QObject *parent=nullptr)
 
 ~QAbstractEventDispatcher ()
 
bool filterNativeEvent (const QByteArray &eventType, void *message, long *result)
 
virtual void flush () = 0
 
virtual bool hasPendingEvents () = 0
 
void installNativeEventFilter (QAbstractNativeEventFilter *filterObj)
 
virtual void interrupt () = 0
 
virtual bool processEvents (QEventLoop::ProcessEventsFlags flags) = 0
 
virtual QList< QTimerInfo > registeredTimers (QObject *object) const = 0
 
virtual bool registerEventNotifier (QWinEventNotifier *notifier) = 0
 
virtual void registerSocketNotifier (QSocketNotifier *notifier) = 0
 
int registerTimer (int interval, Qt::TimerType timerType, QObject *object)
 
virtual void registerTimer (int timerId, int interval, Qt::TimerType timerType, QObject *object) = 0
 
virtual int remainingTime (int timerId) = 0
 
void removeNativeEventFilter (QAbstractNativeEventFilter *filterObj)
 
virtual void unregisterEventNotifier (QWinEventNotifier *notifier) = 0
 
virtual void unregisterSocketNotifier (QSocketNotifier *notifier) = 0
 
virtual bool unregisterTimer (int timerId) = 0
 
virtual bool unregisterTimers (QObject *object) = 0
 
virtual void wakeUp () = 0
 
- Public Methods inherited from QObject
 QObject (QObject *parent=nullptr)
 
 ~QObject ()
 
bool blockSignals (bool block)
 
const QList< QObject * > & children () const
 
bool connect (const QObject *sender, const QString &signalMethod, const QString &location, const QString &slotMethod, Qt::ConnectionType type=Qt::AutoConnection)
 
bool connect (const QObject *sender, const QString &signalMethod, const QString &slotMethod, Qt::ConnectionType type=Qt::AutoConnection)
 
bool disconnect (const QObject *receiver, const QString &slotMethod=QString ()) const
 
bool disconnect (const QString &signalMethod, const QString &location, const QObject *receiver=nullptr, const QString &slotMethod=QString ()) const
 
bool disconnect (const QString &signalMethod=QString (), const QObject *receiver=nullptr, const QString &slotMethod=QString ()) const
 
void dumpObjectInfo ()
 
void dumpObjectTree ()
 
QList< QStringdynamicPropertyNames () const
 
virtual bool event (QEvent *event)
 
virtual bool eventFilter (QObject *watched, QEvent *event)
 
template<typename T >
findChild (const QString &childName=QString ()) const
 
template<class T >
QList< T > findChildren (const QRegularExpression &regExp, Qt::FindChildOptions options=Qt::FindChildrenRecursively) const
 
template<class T >
QList< T > findChildren (const QString &childName=QString (), Qt::FindChildOptions options=Qt::FindChildrenRecursively) const
 
bool inherits (const QString &className) const
 
void installEventFilter (QObject *filterObj)
 
bool isWidgetType () const
 
bool isWindowType () const
 
void killTimer (int id)
 
const QMetaObjectmetaObject () const
 
void moveToThread (QThread *targetThread)
 
QString objectName () const
 
QObject * parent () const
 
template<class T = QVariant>
property (const QString &name) const
 
void removeEventFilter (QObject *obj)
 
void setObjectName (const QString &name)
 
void setParent (QObject *parent)
 
bool setProperty (const QString &name, const QVariant &value)
 
bool signalsBlocked () const
 
int startTimer (int interval, Qt::TimerType timerType=Qt::CoarseTimer)
 
QThreadthread () const
 

Static Public Methods

static QAbstractEventDispatcher * instance (QThread *thread=nullptr)
 
- Static Public Methods inherited from QObject
static bool connect (const QObject *sender, const QMetaMethod &signalMethod, const QObject *receiver, const QMetaMethod &slotMethod, Qt::ConnectionType type=Qt::AutoConnection)
 
static bool connect (const QObject *sender, const QString &signalMethod, const QObject *receiver, const QString &slotMethod, Qt::ConnectionType type=Qt::AutoConnection, const QString &location=QString ())
 
static bool connect (const QObject *sender, const QString &signalMethod, const QString &location, const QObject *receiver, const QString &slotMethod, Qt::ConnectionType type=Qt::AutoConnection)
 
template<class Sender , class SignalClass , class... SignalArgs, class Receiver , class SlotClass , class... SlotArgs, class SlotReturn >
static bool connect (const Sender *sender, void (SignalClass::*signalMethod)(SignalArgs...), const Receiver *receiver, SlotReturn (SlotClass::*slotMethod)(SlotArgs...), Qt::ConnectionType type=Qt::AutoConnection)
 
template<class Sender , class SignalClass , class... SignalArgs, class Receiver , class T >
static bool connect (const Sender *sender, void (SignalClass::*signalMethod)(SignalArgs...), const Receiver *receiver, T slotLambda, Qt::ConnectionType type=Qt::AutoConnection)
 
static bool disconnect (const QObject *sender, const QMetaMethod &signalMethod, const QObject *receiver, const QMetaMethod &slotMethod)
 
static bool disconnect (const QObject *sender, const QString &signalMethod, const QObject *receiver, const QString &slotMethod)
 
static bool disconnect (const QObject *sender, const QString &signalMethod, const QString &location, const QObject *receiver, const QString &slotMethod)
 
static bool disconnect (const QObject *sender, std::nullptr_t, const QObject *receiver, std::nullptr_t)
 
template<class Sender , class SignalClass , class... SignalArgs, class Receiver , class SlotClass , class... SlotArgs, class SlotReturn >
static bool disconnect (const Sender *sender, void (SignalClass::*signalMethod)(SignalArgs...), const Receiver *receiver, SlotReturn (SlotClass::*slotMethod)(SlotArgs...))
 
template<class Sender , class SignalClass , class... SignalArgs, class Receiver >
static bool disconnect (const Sender *sender, void (SignalClass::*signalMethod)(SignalArgs...), const Receiver *receiver, std::nullptr_t slotMethod=nullptr)
 
template<class Sender , class SignalClass , class... SignalArgs, class Receiver , class T >
static bool disconnect (const Sender *sender, void (SignalClass::*signalMethod)(SignalArgs...), const Receiver *receiver, T slotMethod)
 
static QMetaObjectstaticMetaObject ()
 
static QString tr (const char *text, const char *comment=nullptr, std::optional< int > numArg=std::optional< int >())
 

Additional Inherited Members

- Public Slots inherited from QObject
void deleteLater ()
 
- Protected Methods inherited from QObject
virtual void childEvent (QChildEvent *event)
 
virtual void connectNotify (const QMetaMethod &signalMethod) const
 
virtual void customEvent (QEvent *event)
 
virtual void disconnectNotify (const QMetaMethod &signalMethod) const
 
bool isSignalConnected (const QMetaMethod &signalMethod) const
 
int receivers (const QString &signal) const
 
QObject * sender () const
 
int senderSignalIndex () const
 
virtual void timerEvent (QTimerEvent *event)
 
- Properties inherited from QObject
 objectName
 

Detailed Description

An event dispatcher receives events from the window system and other sources. It then sends them to the QCoreApplication or QApplication instance for processing and delivery. QAbstractEventDispatcher provides fine-grained control over event delivery.

For simple control of event processing use QCoreApplication::processEvents().

For finer control of the application's event loop, call instance() and call functions on the QAbstractEventDispatcher object that is returned. If you want to use your own instance of QAbstractEventDispatcher or of a QAbstractEventDispatcher subclass, you must create your instance before you create the QApplication object.

The main event loop is started by calling QCoreApplication::exec(), and stopped by calling QCoreApplication::exit(). Local event loops can be created using QEventLoop.

Programs that perform long operations can call processEvents() with a bitwise OR combination of various QEventLoop::ProcessEventsFlag values to control which events should be delivered.

QAbstractEventDispatcher also allows the integration of an external event loop with the CopperSpice event loop.

See also
QEventLoop, QCoreApplication

Constructor & Destructor Documentation

QAbstractEventDispatcher::QAbstractEventDispatcher ( QObject parent = nullptr)
explicit

Constructs a new event dispatcher with the given parent.

QAbstractEventDispatcher::~QAbstractEventDispatcher ( )

Destroys the event dispatcher.

Method Documentation

void QAbstractEventDispatcher::aboutToBlock ( )
signal

This signal is emitted before the event loop calls a function that could block.

See also
awake()
void QAbstractEventDispatcher::awake ( )
signal

This signal is emitted after the event loop returns from a function that could block.

See also
wakeUp(), aboutToBlock()
bool QAbstractEventDispatcher::filterNativeEvent ( const QByteArray eventType,
void *  message,
long *  result 
)

Sends message through the event filters that were set by installNativeEventFilter(). This function returns true as soon as an event filter returns true, and false otherwise to indicate that the processing of the event should continue.

Subclasses of QAbstractEventDispatcher must call this function for all messages received from the system to ensure compatibility with any extensions that may be used in the application. The type of event eventType is specific to the platform plugin chosen at runtime, and can be used to cast message to the right type. The result pointer is only used on Windows, and corresponds to the LRESULT pointer.

The type of message is platform dependent. Refer to QAbstractNativeEventFilter for more details.

See also
installNativeEventFilter(), QAbstractNativeEventFilter::nativeEventFilter()
void QAbstractEventDispatcher::flush ( )
pure virtual

Flushes the event queue. This normally returns almost immediately. Does nothing on platforms other than X11.

bool QAbstractEventDispatcher::hasPendingEvents ( )
pure virtual

Returns true if there is an event waiting, otherwise returns false.

void QAbstractEventDispatcher::installNativeEventFilter ( QAbstractNativeEventFilter filterObj)

Installs an event filter filterObj for all native event filters received by the application.

The event filter filterObj receives events via its nativeEventFilter() function, which is called for all events received by all threads.

The nativeEventFilter() function should return true if the event should be filtered, (in this case, stopped). It should return false to allow normal processing to continue. The native event can then be translated into a QEvent and handled by the standard event filtering, e.g. QObject::installEventFilter().

If multiple event filters are installed, the filter that was installed last is activated first. The filter function set here receives native messages, that is, MSG or XEvent structs. For maximum portability, you should always try to use QEvent objects and QObject::installEventFilter() whenever possible.

See also
QObject::installEventFilter()
QAbstractEventDispatcher * QAbstractEventDispatcher::instance ( QThread thread = nullptr)
static

Returns a pointer to the event dispatcher object for the specified thread. If thread is a nullptr, the current thread is used. If no event dispatcher exists for the specified thread, this function returns a nullptr.

void QAbstractEventDispatcher::interrupt ( )
pure virtual

Interrupts event dispatching which means the event dispatcher will return from processEvents() as soon as possible.

bool QAbstractEventDispatcher::processEvents ( QEventLoop::ProcessEventsFlags  flags)
pure virtual

Processes pending events which match the given flags until there are no more events to process. Returns true if an event was processed, otherwise returns false. This method returns when there are no more pending events.

This method is useful when there is a long operation and you want to show progress without allowing user input. For this to happen, pass the enum value QEventLoop::ExcludeUserInputEvents in the flags parameter.

If the flags value does not contain QEventLoop::WaitForMoreEvents and no events are available, this method will return immediately. If flags does contain QEventLoop::WaitForMoreEvents, the behavior is as follows.

  • If events are available, returns after processing them.
  • If no events are available, wait until more are available and return after processing newly available events.
See also
hasPendingEvents()
QList< QTimerInfo > QAbstractEventDispatcher::registeredTimers ( QObject object) const
pure virtual

Returns a list of registered timers for object. The timer ID is the first member in each pair, the interval is the second.

bool QAbstractEventDispatcher::registerEventNotifier ( QWinEventNotifier notifier)
pure virtual

This pure virtual method exists on windows only and has to be reimplemented by a Windows specific event dispatcher implementation. The parameter notifier is the QWinEventNotifier instance to be registered. The method should return true if the registration of notifier was successful, otherwise false.

QWinEventNotifier calls this method in its constructor and there should never be a need to call this method directly.

See also
QWinEventNotifier, unregisterEventNotifier()
void QAbstractEventDispatcher::registerSocketNotifier ( QSocketNotifier notifier)
pure virtual

Registers notifier with the event loop. Subclasses must implement this method to tie a socket notifier into another event loop.

int QAbstractEventDispatcher::registerTimer ( int  interval,
Qt::TimerType  timerType,
QObject object 
)

Registers a timer with the specified interval and timerType for the given object.

void QAbstractEventDispatcher::registerTimer ( int  timerId,
int  interval,
Qt::TimerType  timerType,
QObject object 
)
pure virtual

Register a timer with the specified timerId, interval, and timerType for the given object.

int QAbstractEventDispatcher::remainingTime ( int  timerId)
pure virtual

Returns the remaining time in milliseconds with the given timerId. If the timer is inactive, the returned value will be -1. If the timer is overdue, the returned value will be 0.

See also
Qt::TimerType
void QAbstractEventDispatcher::removeNativeEventFilter ( QAbstractNativeEventFilter filterObj)

Removes the event filter filterObj from this object. The request is ignored if such an event filter has not been installed. All event filters for this object are automatically removed when this object is destroyed.

It is always safe to remove an event filter, even during event filter activation.

See also
installNativeEventFilter(), QAbstractNativeEventFilter
void QAbstractEventDispatcher::unregisterEventNotifier ( QWinEventNotifier notifier)
pure virtual

This pure virtual method exists on windows only and has to be reimplemented by a Windows specific event dispatcher implementation. The parameter notifier is the QWinEventNotifier instance to be unregistered.

QWinEventNotifier calls this method in the destructor and there should never be a need to call this method directly.

See also
QWinEventNotifier, registerEventNotifier()
void QAbstractEventDispatcher::unregisterSocketNotifier ( QSocketNotifier notifier)
pure virtual

Unregisters notifier from the event dispatcher. Subclasses must reimplement this method to tie a socket notifier into another event loop. Reimplementations must call the base implementation.

bool QAbstractEventDispatcher::unregisterTimer ( int  timerId)
pure virtual

Unregisters the timer with the given timerId. Returns true if successful, otherwise returns false.

See also
registerTimer(), unregisterTimers()
bool QAbstractEventDispatcher::unregisterTimers ( QObject object)
pure virtual

Unregisters all the timers associated with the given object. Returns true if all timers were successful removed, otherwise returns false.

See also
unregisterTimer(), registeredTimers()
void QAbstractEventDispatcher::wakeUp ( )
pure virtual

Wakes up the event loop.

Note
This method is thread-safe.
See also
awake()