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