- Game Programming using Qt 5 Beginner's Guide
- Pavel Strakhov Witold Wysota Lorenz Haas
- 87字
- 2021-08-27 18:31:03
Have a go hero – Implementing the custom rectangle as a class
In this example, we avoided creating a class for our custom rectangle to keep the code as simple as possible. Following the principles of object-oriented programming, subclassing QGraphicsRectItem and creating children items in the constructor of the new class is a good idea. Doing this doesn't require anything you don't already know. For example, when subclassing QGraphicsRectItem, you don't need to implement any virtual functions, because they are all properly implemented in the base classes.