Time for action – Hiding properties

If we convert our heartbeat canvas to a QML component, the points and arg properties will be the public properties visible to the user of the component. However, they are really implementation details we want to hide. We should only expose properties that make sense to the user of the component, such as lineWidth or color.

Since the Timer object inside the Canvas is not exported as public property, that timer object will be unavailable from the outside, so we can attach properties to the timer instead of attaching them to the top-level Canvas object. However, the properties do not belong to the timer logically, so this solution will be confusing. For such cases, there is a convention that you should create ...

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

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.