Movatterモバイル変換


[0]ホーム

URL:


We bake cookies in your browser for a better experience. Using this site means that you consent.Read More

Menu

Qt Documentation

QAbstractEventDispatcher Class

TheQAbstractEventDispatcher class provides an interface to manage Qt's event queue.More...

Header:#include <QAbstractEventDispatcher>
Inherits:QObject

Public Types

typedefEventFilter
typedefTimerInfo

Public Functions

QAbstractEventDispatcher(QObject * parent = 0)
~QAbstractEventDispatcher()
boolfilterEvent(void * message)
virtual voidflush() = 0
virtual boolhasPendingEvents() = 0
virtual voidinterrupt() = 0
virtual boolprocessEvents(QEventLoop::ProcessEventsFlags flags) = 0
virtual voidregisterSocketNotifier(QSocketNotifier * notifier) = 0
intregisterTimer(int interval, QObject * object)
virtual voidregisterTimer(int timerId, int interval, QObject * object) = 0
virtual QList<TimerInfo>registeredTimers(QObject * object) const = 0
EventFiltersetEventFilter(EventFilter filter)
virtual voidunregisterSocketNotifier(QSocketNotifier * notifier) = 0
virtual boolunregisterTimer(int timerId) = 0
virtual boolunregisterTimers(QObject * object) = 0
virtual voidwakeUp() = 0
  • 29 public functions inherited fromQObject

Signals

voidaboutToBlock()
voidawake()

Static Public Members

QAbstractEventDispatcher *instance(QThread * thread = 0)
  • 7 static public members inherited fromQObject

Additional Inherited Members

  • 1 property inherited fromQObject
  • 1 public slot inherited fromQObject
  • 8 protected functions inherited fromQObject

Detailed Description

TheQAbstractEventDispatcher class provides an interface to manage Qt's event queue.

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

For simple control of event processing useQCoreApplication::processEvents().

For finer control of the application's event loop, callinstance() and call functions on theQAbstractEventDispatcher object that is returned. If you want to use your own instance ofQAbstractEventDispatcher or of aQAbstractEventDispatcher subclass, you must create your instancebefore you create theQApplication object.

The main event loop is started by callingQCoreApplication::exec(), and stopped by callingQCoreApplication::exit(). Local event loops can be created usingQEventLoop.

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

QAbstractEventDispatcher also allows the integration of an external event loop with the Qt event loop. For example, theMotif Extension includes a reimplementation ofQAbstractEventDispatcher that merges Qt and Motif events together.

See alsoQEventLoop andQCoreApplication.

Member Type Documentation

typedef QAbstractEventDispatcher::EventFilter

Typedef for a function with the signature

bool myEventFilter(void*message);

Note that the type of themessage is platform dependent. The following table shows themessage's type on Windows, Mac, X11 and BlackBerry. You can do a static cast to these types.

Platformtype
WindowsMSG
X11XEvent
MacNSEvent
BlackBerrybps_event_t

See alsosetEventFilter() andfilterEvent().

typedef QAbstractEventDispatcher::TimerInfo

Typedef forQPair<int, int>. The first component of the pair is the timer ID; the second component is the interval.

See alsoregisteredTimers().

Member Function Documentation

QAbstractEventDispatcher::QAbstractEventDispatcher(QObject * parent = 0)

Constructs a new event dispatcher with the givenparent.

QAbstractEventDispatcher::~QAbstractEventDispatcher()

Destroys the event dispatcher.

[signal]void QAbstractEventDispatcher::aboutToBlock()

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

See alsoawake().

[signal]void QAbstractEventDispatcher::awake()

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

See alsowakeUp() andaboutToBlock().

bool QAbstractEventDispatcher::filterEvent(void * message)

Sendsmessage through the event filter that was set bysetEventFilter(). If no event filter has been set, this function returns false; otherwise, this function returns the result of the event filter function.

Subclasses ofQAbstractEventDispatchermust call this function forall messages received from the system to ensure compatibility with any extensions that may be used in the application.

Note that the type ofmessage is platform dependent. SeeQAbstractEventDispatcher::EventFilter for details.

See alsosetEventFilter().

[pure virtual]void QAbstractEventDispatcher::flush()

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

[pure virtual]bool QAbstractEventDispatcher::hasPendingEvents()

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

[static]QAbstractEventDispatcher * QAbstractEventDispatcher::instance(QThread * thread = 0)

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

Note: If Qt is built without thread support, thethread argument is ignored.

[pure virtual]void QAbstractEventDispatcher::interrupt()

Interrupts event dispatching; i.e. the event dispatcher will return fromprocessEvents() as soon as possible.

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

Processes pending events that matchflags until there are no more events to process. Returns true if an event was processed; otherwise returns false.

This function is especially useful if you have a long running operation and want to show its progress without allowing user input; i.e. by using theQEventLoop::ExcludeUserInputEvents flag.

If theQEventLoop::WaitForMoreEvents flag is set inflags, the behavior of this function is as follows:

  • If events are available, this function returns after processing them.
  • If no events are available, this function will wait until more are available and return after processing newly available events.

If theQEventLoop::WaitForMoreEvents flag is not set inflags, and no events are available, this function will return immediately.

Note: This function does not process events continuously; it returns after all available events are processed.

See alsohasPendingEvents().

[pure virtual]void QAbstractEventDispatcher::registerSocketNotifier(QSocketNotifier * notifier)

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

int QAbstractEventDispatcher::registerTimer(int interval,QObject * object)

Registers a timer with the specifiedinterval for the givenobject.

[pure virtual]void QAbstractEventDispatcher::registerTimer(int timerId,int interval,QObject * object)

Register a timer with the specifiedtimerId andinterval for the givenobject.

[pure virtual]QList<TimerInfo> QAbstractEventDispatcher::registeredTimers(QObject * object) const

Returns a list of registered timers forobject. The timer ID is the first member in each pair; the interval is the second.

EventFilter QAbstractEventDispatcher::setEventFilter(EventFilter filter)

Replaces the event filter function for thisQAbstractEventDispatcher withfilter and returns the replaced event filter function. Only the current event filter function is called. If you want to use both filter functions, save the replacedEventFilter in a place where yours can call it.

The event filter function set here is called for all messages taken from the system event loop before the event is dispatched to the respective target, including the messages not meant for Qt objects.

The event filter function should return true if the message should be filtered, (i.e. stopped). It should return false to allow processing the message to continue.

By default, no event filter function is set (i.e., this function returns a nullEventFilter the first time it is called).

[pure virtual]void QAbstractEventDispatcher::unregisterSocketNotifier(QSocketNotifier * notifier)

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

[pure virtual]bool QAbstractEventDispatcher::unregisterTimer(int timerId)

Unregisters the timer with the giventimerId. Returns true if successful; otherwise returns false.

See alsoregisterTimer() andunregisterTimers().

[pure virtual]bool QAbstractEventDispatcher::unregisterTimers(QObject * object)

Unregisters all the timers associated with the givenobject. Returns true if all timers were successful removed; otherwise returns false.

See alsounregisterTimer() andregisteredTimers().

[pure virtual]void QAbstractEventDispatcher::wakeUp()

Wakes up the event loop.

Note: This function isthread-safe.

See alsoawake().

© 2016 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of theGNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.


[8]ページ先頭

©2009-2025 Movatter.jp