Viadeo Twitter Google Bookmarks ! Facebook Digg del.icio.us MySpace Yahoo MyWeb Blinklist Netvouz Reddit Simpy StumbleUpon Bookmarks Windows Live Favorites 
Logo Documentation Qt ·  Page d'accueil  ·  Toutes les classes  ·  Classes principales  ·  Annotées  ·  Classes groupées  ·  Modules  ·  Fonctions  · 

QAbstractEventDispatcher Class

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

 #include <QAbstractEventDispatcher>

Inherits: QObject.

Inherited by: QWindowsGuiEventDispatcher.

Public Types

class TimerInfo
typedef EventFilter

Public Functions

QAbstractEventDispatcher(QObject * parent = 0)
~QAbstractEventDispatcher()
bool filterEvent(void * message)
virtual void flush() = 0
virtual bool hasPendingEvents() = 0
virtual void interrupt() = 0
virtual bool processEvents(QEventLoop::ProcessEventsFlags flags) = 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 QList<TimerInfo> registeredTimers(QObject * object) const = 0
virtual int remainingTime(int timerId) = 0
EventFilter setEventFilter(EventFilter filter)
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
  • 31 public functions inherited from QObject

Signals

void aboutToBlock()
void awake()

Static Public Members

QAbstractEventDispatcher * instance(QThread * thread = 0)
  • 11 static public members inherited from QObject

Additional Inherited Members

  • 1 property inherited from QObject
  • 1 public slot inherited from QObject
  • 9 protected functions inherited from QObject

Detailed Description

The QAbstractEventDispatcher 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 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 install it with QCoreApplication::setEventDispatcher() or QThread::setEventDispatcher() before a default event dispatcher has been installed.

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 Qt event loop. For example, the Motif Extension includes a reimplementation of QAbstractEventDispatcher that merges Qt and Motif events together.

See also QEventLoop, QCoreApplication, and QThread.

Member Type Documentation

typedef QAbstractEventDispatcher::EventFilter

Typedef for a function with the signature

 bool myEventFilter(void *message);

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

Platformtype
WindowsMSG
X11XEvent
MacNSEvent

See also setEventFilter() and filterEvent().

Member Function Documentation

QAbstractEventDispatcher::QAbstractEventDispatcher(QObject * parent = 0)

Constructs a new event dispatcher with the given parent.

QAbstractEventDispatcher::~QAbstractEventDispatcher()

Destroys the event dispatcher.

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() and aboutToBlock().

bool QAbstractEventDispatcher::filterEvent(void * message)

Sends message through the event filter that was set by setEventFilter(). If no event filter has been set, this function returns false; otherwise, this function returns the result of the event filter function.

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.

Note that the type of message is platform dependent. See QAbstractEventDispatcher::EventFilter for details.

See also setEventFilter().

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.

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

Returns a pointer to the event dispatcher object for the specified thread. If thread 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, the thread argument is ignored.

void QAbstractEventDispatcher::interrupt() [pure virtual]

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

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

Processes pending events that match flags 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 the QEventLoop::ExcludeUserInputEvents flag.

If the QEventLoop::WaitForMoreEvents flag is set in flags, 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 the QEventLoop::WaitForMoreEvents flag is not set in flags, 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 also hasPendingEvents().

bool QAbstractEventDispatcher::registerEventNotifier(QWinEventNotifier * notifier) [pure virtual]

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 and returns the timer id.

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.

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

Returns a list of registered timers for object. The TimerInfo struct has timerId, interval, and timerType members.

See also Qt::TimerType.

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.

EventFilter QAbstractEventDispatcher::setEventFilter(EventFilter filter)

Replaces the event filter function for this QAbstractEventDispatcher with filter 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 replaced EventFilter 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 null EventFilter the first time it is called).

void QAbstractEventDispatcher::unregisterEventNotifier(QWinEventNotifier * notifier) [pure virtual]

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() and 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() and registeredTimers().

void QAbstractEventDispatcher::wakeUp() [pure virtual]

Wakes up the event loop.

Note: This function is thread-safe.

See also awake().

Cette page est une traduction d'une page de la documentation de Qt, écrite par Nokia Corporation and/or its subsidiary(-ies). Les éventuels problèmes résultant d'une mauvaise traduction ne sont pas imputables à Nokia. Qt 5.0-snapshot
Copyright © 2012 Developpez LLC. Tous droits réservés Developpez LLC. Aucune reproduction, même partielle, ne peut être faite de ce site et de l'ensemble de son contenu : textes, documents et images sans l'autorisation expresse de Developpez LLC. Sinon, vous encourez selon la loi jusqu'à 3 ans de prison et jusqu'à 300 000 E de dommages et intérêts. Cette page est déposée à la SACD.
Vous avez déniché une erreur ? Un bug ? Une redirection cassée ? Ou tout autre problème, quel qu'il soit ? Ou bien vous désirez participer à ce projet de traduction ? N'hésitez pas à nous contacter ou par MP !
 
 
 
 
Partenaires

Hébergement Web