Fixed deprecated method QFontMetrics::width (#2509)

Co-authored-by: pajlada <rasmus.karlsson@pajlada.com>
This commit is contained in:
Paweł
2021-03-13 14:47:02 +01:00
committed by GitHub
parent d94d9e74dd
commit 0e99527e8c
5 changed files with 19 additions and 16 deletions
+3 -2
View File
@@ -106,7 +106,7 @@ void Label::paintEvent(QPaintEvent *)
// draw text
QRect textRect(offset, 0, this->width() - offset - offset, this->height());
int width = metrics.width(this->text_);
int width = metrics.horizontalAdvance(this->text_);
Qt::Alignment alignment = !this->centered_ || width > textRect.width()
? Qt::AlignLeft | Qt::AlignVCenter
: Qt::AlignCenter;
@@ -128,7 +128,8 @@ void Label::updateSize()
QFontMetrics metrics =
getFonts()->getFontMetrics(this->fontStyle_, this->scale());
int width = metrics.width(this->text_) + (2 * this->getOffset());
int width =
metrics.horizontalAdvance(this->text_) + (2 * this->getOffset());
int height = metrics.height();
this->preferedSize_ = QSize(width, height);