QPointF pos = ratingTextInfo->pos;
const Qt::Alignment align = ratingTextInfo->staticText.textOption().alignment();
if (align & Qt::AlignHCenter) {
- pos.rx() += (size().width() - m_rating.width()) / 2 - 2;
+ pos.rx() += (size().width() - m_rating.width() / m_rating.devicePixelRatioF()) / 2 - 2;
}
painter->drawPixmap(pos, m_rating);
}
requiredWidth = m_customizedFontMetrics.horizontalAdvance(elidedText);
} else if (role == "rating") {
// Use the width of the rating pixmap, because the rating text is empty.
- requiredWidth = m_rating.width();
+ requiredWidth = m_rating.width() / m_rating.devicePixelRatioF();
}
}
layout.endLayout();
textInfo->staticText.setTextWidth(maxWidth);
const QRectF textRect(padding + (maxWidth - requiredWidth) / 2, y, requiredWidth, lineSpacing);
- m_textRect |= textRect;
+
+ // Ignore empty roles. Avoids a text rect taller than the area that actually contains text.
+ if (!textRect.isEmpty()) {
+ m_textRect |= textRect;
+ }
y += lineSpacing;
}