20void QQuickUniversalFocusRectangle::paint(QPainter *painter)
22 if (!isVisible() || width() <= 0 || height() <= 0)
25 QRect bounds = boundingRect().toAlignedRect();
26 const int boundsWidth = bounds.width();
27 const int boundsHeight = bounds.width();
28 const QString key = QStringLiteral(
"qquickuniversalfocusrectangle_%1_%2").arg(QString::number(boundsWidth), QString::number(boundsHeight));
30 QPixmap pixmap(boundsWidth, boundsHeight);
31 if (!QPixmapCache::find(key, &pixmap)) {
32 bounds.adjust(0, 0, -1, -1);
33 pixmap.fill(Qt::transparent);
38 pen.setColor(Qt::white);
42 pen.setColor(Qt::black);
43 pen.setDashPattern(QList<qreal>(2, 1));
47 QPixmapCache::insert(key, pixmap);
49 painter->drawPixmap(0, 0, pixmap);