Game Programming using Qt 5 Beginner's Guide
上QQ阅读APP看书,第一时间看更新

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.