Use the same logic Qt default styles use when drawing text for QStyle::CE_ItemViewItem.
Before:
After: