Event handler 2026-11-05
An event handler is code invoked to respond to a particular software event, such as a key press, resize or completed operation. The event's data identifies what happened; the event handler interprets it using the application's current state. Qt dispatches an event object to its target and then to an appropriate event-specific method.[ref]
For example, a resize event handler can recompute a plot's displayed layout from the new dimensions. A later paint software event draws that layout. Keeping each response short lets an event loop handle other work promptly. When delivery is delayed, the application's state may already have changed, so the original occurrence and its eventual handling must be distinguished.
Event loop 2026-11-05
An event loop repeatedly obtains pending software events and dispatches them to their event handlers, waiting when no work is available. This lets one thread service many intermittent activities without a separate continuously running loop for each. Qt's application event loop dispatches timer, network and other software events.[ref]
Suppose a button starts a calculation that takes ten seconds. Running that calculation synchronously inside its event handler prevents the same event loop from repainting or processing further clicks during those ten seconds. Dividing the work into short steps or delegating it to another thread lets the event handler return. An event loop coordinates readiness and dispatch; it does not itself provide parallel computing for long computations.
Software event 2026-11-05
A software event represents an occurrence that a program can observe and handle, such as a key press, timer expiry or completed operation. It may carry data identifying what happened, where and to which object. An event handler performs the relevant response; an event loop commonly dispatches pending events to their destinations.
In Qt, an event object is delivered to a target object whose event method dispatches to a type-specific handler. Mouse, keyboard, resize and timer events carry different information.[ref] A queued event can be handled after the original occurrence, so event time and handling time differ. Reentrant or asynchronous handlers must also account for changes in application state between those moments.