Game Programming using Qt 5 Beginner's Guide - Second Edition
by Pavel Strakhov, Witold Wysota, Lorenz Haas
Signals and slots
To trigger functionality as a response to something that happens in an application, Qt uses a mechanism of signals and slots. This is another important feature of the QObject class. It's based on connecting a notification (which Qt calls a signal) about a change of state in some object with a function or method (called a slot) that is executed when such a notification arises. For example, if a button is pressed, it emits (sends) a clicked() signal. If some method is connected to this signal, the method will be called whenever the button is pressed.
Signals can have arguments that serve as a payload. For example, an input box widget (QLineEdit) has a textEdited(const QString &text) signal that's emitted when the user edits ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access