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);
}
QString ret = m_customizedFontMetrics.elidedText(text.chopped(extensionLength),
Qt::ElideRight,
elidingWidth - extensionWidth);
+#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
ret.append(text.rightRef(extensionLength));
+#else
+ ret.append(QStringView(text).right(extensionLength));
+#endif
return ret;
}
}
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;
}