Skip to content

Commit

Permalink
Add a missing 2 muliplier for the frame width and the releated descri…
Browse files Browse the repository at this point in the history
…ption
  • Loading branch information
daschuer committed Feb 4, 2023
1 parent 6ffdbd3 commit 29c3bbc
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/widget/wlabel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,11 @@ void WLabel::setText(const QString& text) {
if (m_elideMode != Qt::ElideNone) {
QFontMetrics metrics(font());
// Measure the text for label width
m_widthHint = metrics.size(0, m_longText).width() + frameWidth();
QString elidedText = metrics.elidedText(m_longText, m_elideMode, width() - frameWidth());
// frameWidth() is the maximum of the sum of margin, border and padding
// width of the left and the right side.
m_widthHint = metrics.size(0, m_longText).width() + 2 * frameWidth();
QString elidedText = metrics.elidedText(
m_longText, m_elideMode, width() - 2 * frameWidth());
QLabel::setText(elidedText);
} else {
QLabel::setText(m_longText);
Expand Down

0 comments on commit 29c3bbc

Please sign in to comment.