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?

In the last exercise, we learned to use some properties and signals from MouseArea to make the button component more interactive. However, the element is much richer in features. In particular, if hover events are enabled, you can get the current mouse position in the item's local coordinate system through the mouseX and mouseY properties that return values. The cursor position can also be reported by handling the positionChanged signal. Speaking of signals, most MouseArea signals carry a MouseEvent object as their argument. This argument is called mouse and contains useful information about the current state of the mouse, including its position and buttons currently pressed. By default, MouseArea only reacts to the left ...

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