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 ...

Get Game Programming using Qt 5 Beginner's Guide - Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.