Game Programming using Qt 5 Beginner's Guide - Second Edition
by Pavel Strakhov, Witold Wysota, Lorenz Haas
What just happened?
With the signal clicked() statement, we declared that the button object can emit a signal called clicked. With the MouseArea item, we defined a rectangular area (covering the whole button) that reacts to mouse events. Then, we defined onClicked, which is a signal handler. For every signal an object has, a script can be bound to a handler named like the signal and prefixed with "on"; hence, for the clicked signal, the handler is called onClicked, and, for valueChanged, it is called onValueChanged.
In this particular case, we have two handlers defined—one for the button where we write a simple statement to the console, and the other for the MouseArea element where we call the button's signal function, effectively emitting ...
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