Skip to content

Commit

Permalink
Pass the alignment to QFontMetrics::elidedText()
Browse files Browse the repository at this point in the history
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 <[email protected]>
Reviewed-by: Richard Moe Gustavsen <[email protected]>
  • Loading branch information
AndyShawQt committed Dec 21, 2018
1 parent 4aac07d commit c879fc2
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/widgets/styles/qcommonstyle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit c879fc2

Please sign in to comment.