Game Programming using Qt 5 Beginner's Guide - Second Edition
by Pavel Strakhov, Witold Wysota, Lorenz Haas
What just happened?
We added two kinds of properties to the element. By introducing lineWidth, we can manipulate the width of the line that visualizes the heartbeat. The points variable stores an array of already calculated function values. We initialize it to an empty array. The arg variable stores the function argument that was last evaluated. The argument of the function should be in the range from −π to +π; thus, we initialize arg to -Math.PI. Then, we add a timer that ticks in regular intervals, incrementing arg by 1° until it reaches +π, in which case it is reset to the initial value.
Changes to arg are intercepted in the handler we implement next. In there, we push a new item to the array of points. The value is calculated by the ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access