Now we'll start implementing the coin class. We can use a simple QGraphicsEllipseItem object, but we'll need to animate its properties, so let's create a new Coin class and derive it from QObject and QGraphicsEllipseItem. Define two properties: opacity of the qreal type and rect of the QRect type. This is done only by the following code:
class Coin : public QObject, public QGraphicsEllipseItem{ Q_OBJECT Q_PROPERTY(qreal opacity READ opacity WRITE setOpacity) Q_PROPERTY(QRectF rect READ rect WRITE setRect)//...};
No function or slot was added, because we simply used built-in functions of QGraphicsItem and associated them with the properties.