QComboBox/Fusion style: elide text when it's too long

The fusion style did not elide a very long text in a QComboBox as it's
done in other styles / non-popup mode.

Fixes: QTBUG-86632
Change-Id: I356a61809220d41717a9039d2b33dd706d034941
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
(cherry picked from commit 1a9095e1fa4bb5d74b91d1661d55893d0e8620e1)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
Christian Ehrlicher 2020-12-22 20:55:19 +01:00 committed by Qt Cherry-pick Bot
parent 684f26caad
commit f9f0238557

View File

@ -1723,12 +1723,13 @@ void QFusionStyle::drawControl(ControlElement element, const QStyleOption *optio
font.setBold(true);
p->setFont(font);
const QString textToDraw = s.left(t).toString();
QString textToDraw = s.left(t).toString();
if (dis && !act && proxy()->styleHint(SH_EtchDisabledText, option, widget)) {
p->setPen(menuitem->palette.light().color());
p->drawText(vTextRect.adjusted(1, 1, 1, 1), text_flags, textToDraw);
p->setPen(discol);
}
textToDraw = menuitem->fontMetrics.elidedText(textToDraw, Qt::ElideMiddle, vTextRect.width());
p->drawText(vTextRect, text_flags, textToDraw);
p->restore();
}