QEvent and its subclasses.1. trigger/handle an event
An event can be triggered from outside of the application (e.g. mouse move, key press), inside the application (e.g. a timer event described by
QTimerEvent), or by a user using QCoreApplication::sendEvent() or QCoreApplication::postEvent().When an event is received by an object,
QObject::event() would be called, which should return true if the event was recognized and processed. This function can be reimplemented as a customized event handler, e.g. QWidget::event() would dispatch a mouse move event to QWidget::mouseMoveEvent().2. accept an event
We can decide whether an event is accepted or not, by calling
QEvent::accept() or QEvent::ignore(). If an event is ignored, it would be sent to the parent of the current handler.Ignoring an event might be useful in some cases, e.g. you can cancel a request to close a widget by reimplementing
QWidget::closeEvent().3. event filters
Events can be filtered before it reaches the receiver. The filter object can be set by calling the
QObject::installEventFilter() function. If more than one filters are installed, the last-installed filter is activated first.If an event filter is installed, any event would first be sent to it, triggering the
QObject::eventFilter() function. This function should return true if the event is to be dropped; otherwise false. Note that it's better to pass the event object to the base class's eventFilter() function, as it might have reimplemented it.
