Time for action – creating an item where transformations can easily be seen
First we set up a playground. To do this, we subclass a QGraphicsRectItem item and customize its paint function as follows:
void ScaleItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) {
Q_UNUSED(option)
Q_UNUSED(widget)
const QPen oldPen = painter->pen();
const QRectF r = rect();
const QColor fillColor = Qt::red;
const qreal square = r.width() / 10.0;
painter->fillRect(QRectF(0, 0, square, square), fillColor);
painter->fillRect(QRectF(r.width() - square, 0, square, square), fillColor);
painter->fillRect(QRectF(0,r.height() - square, square, square), fillColor);
painter->fillRect(QRectF(r.width() - square, r.height() - square,square, square), fillColor);
painter->setPen(Qt::black);
painter->drawRect(r);
painter->drawLine(r.topLeft(), r.bottomRight());
painter->drawLine(r.topRight(), r.bottomLeft());
const qreal padding...