Have a go hero – Extending the item's functionality

The abilities of SineItem are still pretty limited. As an exercise, you can try to add an option to change the minimum x value of the graph or set a different pen. You can even allow the user to specify an arbitrary function pointer to replace the sin() function. However, keep in mind that the bounding rect of the item depends on the value range of the function, so you need to update the item's geometry accurately.

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.