forked from qt-creator/qt-creator
Fix Qt 5.13 deprecation warning about QFontMetrics::width()
Replace by QFontMetrics::horizontalAdvance(), fixing: warning: ‘int QFontMetrics::width(const QString&, int) const’ is deprecated: Use QFontMetrics::horizontalAdvance [-Wdeprecated-declarations] Change-Id: I9991ffefe6e87e872dc35ba291d562e06b28ca64 Reviewed-by: Alessandro Portale <alessandro.portale@qt.io>
This commit is contained in:
@@ -154,7 +154,7 @@ QSize CostDelegate::sizeHint(const QStyleOptionViewItem &option, const QModelInd
|
||||
initStyleOption(&opt, index);
|
||||
|
||||
const QString text = d->displayText(index, opt.locale);
|
||||
const QSize size = QSize(option.fontMetrics.width(text),
|
||||
const QSize size = QSize(option.fontMetrics.horizontalAdvance(text),
|
||||
option.fontMetrics.height());
|
||||
return size;
|
||||
}
|
||||
|
||||
@@ -139,7 +139,7 @@ void FunctionGraphicsTextItem::paint(QPainter *painter,
|
||||
painter->save();
|
||||
int textLeft = 0;
|
||||
int textTop = 0;
|
||||
const int textWidth = painter->fontMetrics().width(m_staticText.text());
|
||||
const int textWidth = painter->fontMetrics().horizontalAdvance(m_staticText.text());
|
||||
textLeft = -textWidth/2;
|
||||
textTop = (maxHeight - textHeight)/2;
|
||||
painter->drawStaticText(textLeft, textTop, m_staticText);
|
||||
|
||||
Reference in New Issue
Block a user