Pass the alignment to QFontMetrics::elidedText()

When the text is elided, it needs to account for the mnenomic if
there is one so it does not end up eliding the text unnecessarily.

Change-Id: I77c15067f3e8d57d8deca83090bcb80554c3733f
Reviewed-by: Christian Ehrlicher <ch.ehrlicher@gmx.de>
Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
This commit is contained in:
Andy Shaw 2018-12-14 07:46:12 +01:00
parent 4aac07d023
commit c879fc2ab7

View File

@ -1675,7 +1675,8 @@ void QCommonStyle::drawControl(ControlElement element, const QStyleOption *opt,
alignment |= Qt::AlignLeft | Qt::AlignVCenter;
}
tr.translate(shiftX, shiftY);
const QString text = toolbutton->fontMetrics.elidedText(toolbutton->text, Qt::ElideMiddle, tr.width());
const QString text = toolbutton->fontMetrics.elidedText(toolbutton->text, Qt::ElideMiddle,
tr.width(), alignment);
proxy()->drawItemText(p, QStyle::visualRect(opt->direction, rect, tr), alignment, toolbutton->palette,
toolbutton->state & State_Enabled, text,
QPalette::ButtonText);