Fixed deprecated method QFontMetrics::width (#2509)
Co-authored-by: pajlada <rasmus.karlsson@pajlada.com>
This commit is contained in:
@@ -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);
|
||||
|
||||
|
||||
@@ -119,11 +119,11 @@ int NotebookTab::normalTabWidth()
|
||||
|
||||
if (this->hasXButton())
|
||||
{
|
||||
width = (metrics.width(this->getTitle()) + int(32 * scale));
|
||||
width = (metrics.horizontalAdvance(this->getTitle()) + int(32 * scale));
|
||||
}
|
||||
else
|
||||
{
|
||||
width = (metrics.width(this->getTitle()) + int(16 * scale));
|
||||
width = (metrics.horizontalAdvance(this->getTitle()) + int(16 * scale));
|
||||
}
|
||||
|
||||
if (this->height() > 150 * scale)
|
||||
@@ -390,7 +390,7 @@ void NotebookTab::paintEvent(QPaintEvent *)
|
||||
textRect.setRight(textRect.right() - this->height() / 2);
|
||||
}
|
||||
|
||||
int width = metrics.width(this->getTitle());
|
||||
int width = metrics.horizontalAdvance(this->getTitle());
|
||||
Qt::Alignment alignment = width > textRect.width()
|
||||
? Qt::AlignLeft | Qt::AlignVCenter
|
||||
: Qt::AlignHCenter | Qt::AlignVCenter;
|
||||
|
||||
Reference in New Issue
Block a user