O'Reilly logo

Game Programming using Qt 5 Beginner's Guide - Second Edition by Lorenz Haas, Witold Wysota, Pavel Strakhov

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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 onClickedand, for valueChangedit 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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required