January 2016
Beginner
512 pages
12h 35m
English
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, ...