From 1a9095e1fa4bb5d74b91d1661d55893d0e8620e1 Mon Sep 17 00:00:00 2001 From: Christian Ehrlicher Date: Tue, 22 Dec 2020 20:55:19 +0100 Subject: 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 Pick-to: 6.0 5.15 Change-Id: I356a61809220d41717a9039d2b33dd706d034941 Reviewed-by: Volker Hilsheimer --- src/widgets/styles/qfusionstyle.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/widgets/styles/qfusionstyle.cpp b/src/widgets/styles/qfusionstyle.cpp index ab5cb80843..b8044dbc09 100644 --- a/src/widgets/styles/qfusionstyle.cpp +++ b/src/widgets/styles/qfusionstyle.cpp @@ -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(); } -- cgit v1.2.3