diff options
author | Christian Ehrlicher <ch.ehrlicher@gmx.de> | 2020-12-22 20:55:19 +0100 |
---|---|---|
committer | Qt Cherry-pick Bot <cherrypick_bot@qt-project.org> | 2021-01-23 17:16:33 +0000 |
commit | f9f0238557a46f1ba4795cacfa1d6702461ed788 (patch) | |
tree | d0bac6c4302a84d9db231a6fee30a6049a023327 /src/widgets/styles/qfusionstyle.cpp | |
parent | 684f26caad745d04dfc85fa4c850e13ea57a4a84 (diff) |
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>
Diffstat (limited to 'src/widgets/styles/qfusionstyle.cpp')
-rw-r--r-- | src/widgets/styles/qfusionstyle.cpp | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/src/widgets/styles/qfusionstyle.cpp b/src/widgets/styles/qfusionstyle.cpp index 8e7005fafa..d6197542c6 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(); } |