Fix error: 'width' is deprecated: Use QFontMetrics::horizontalAdvance.
--HG-- branch : develop
This commit is contained in:
parent
09bd14f382
commit
4a4351b73d
|
@ -1180,7 +1180,11 @@ void VLayoutPiece::CreateLabelStrings(QGraphicsItem *parent, const QVector<QPoin
|
|||
}
|
||||
|
||||
QString qsText = tl.m_qsText;
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(5, 11, 0)
|
||||
if (fm.horizontalAdvance(qsText) > dW)
|
||||
#else
|
||||
if (fm.width(qsText) > dW)
|
||||
#endif
|
||||
{
|
||||
qsText = fm.elidedText(qsText, Qt::ElideMiddle, static_cast<int>(dW));
|
||||
}
|
||||
|
@ -1190,11 +1194,19 @@ void VLayoutPiece::CreateLabelStrings(QGraphicsItem *parent, const QVector<QPoin
|
|||
}
|
||||
else if ((tl.m_eAlign & Qt::AlignHCenter) > 0)
|
||||
{
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(5, 11, 0)
|
||||
dX = (dW - fm.horizontalAdvance(qsText))/2;
|
||||
#else
|
||||
dX = (dW - fm.width(qsText))/2;
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(5, 11, 0)
|
||||
dX = dW - fm.horizontalAdvance(qsText);
|
||||
#else
|
||||
dX = dW - fm.width(qsText);
|
||||
#endif
|
||||
}
|
||||
|
||||
// set up the rotation around top-left corner matrix
|
||||
|
|
|
@ -431,7 +431,11 @@ void VTextManager::FitFontSize(qreal fW, qreal fH)
|
|||
fnt.setBold(tl.m_bold);
|
||||
fnt.setItalic(tl.m_italic);
|
||||
QFontMetrics fm(fnt);
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(5, 11, 0)
|
||||
const int iTW = fm.horizontalAdvance(tl.m_qsText);
|
||||
#else
|
||||
const int iTW = fm.width(tl.m_qsText);
|
||||
#endif
|
||||
if (iTW > iMaxLen)
|
||||
{
|
||||
iMaxLen = iTW;
|
||||
|
@ -450,7 +454,11 @@ void VTextManager::FitFontSize(qreal fW, qreal fH)
|
|||
--iFS;
|
||||
fnt.setPixelSize(iFS + maxLine.m_iFontSize);
|
||||
QFontMetrics fm(fnt);
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(5, 11, 0)
|
||||
lineLength = fm.horizontalAdvance(maxLine.m_qsText);
|
||||
#else
|
||||
lineLength = fm.width(maxLine.m_qsText);
|
||||
#endif
|
||||
}
|
||||
while (lineLength > fW && iFS > MIN_FONT_SIZE);
|
||||
}
|
||||
|
|
|
@ -78,7 +78,7 @@ QSize FancyTabBar::TabSizeHint(bool minimum) const
|
|||
boldFont.setBold(true);
|
||||
QFontMetrics fm(boldFont);
|
||||
int spacing = 8;
|
||||
int width = 60 + spacing + 2;
|
||||
|
||||
int maxLabelwidth = 0;
|
||||
for (int tab=0 ; tab<Count() ;++tab)
|
||||
{
|
||||
|
@ -92,7 +92,11 @@ QSize FancyTabBar::TabSizeHint(bool minimum) const
|
|||
{
|
||||
sentence = sentence.isEmpty() ? sentence = word : sentence + QLatin1Char(' ') + word;
|
||||
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(5, 11, 0)
|
||||
const int width = fm.horizontalAdvance(sentence);
|
||||
#else
|
||||
const int width = fm.width(sentence);
|
||||
#endif
|
||||
if (maxLabelwidth < width)
|
||||
{
|
||||
maxLabelwidth = width;
|
||||
|
@ -102,7 +106,11 @@ QSize FancyTabBar::TabSizeHint(bool minimum) const
|
|||
}
|
||||
else
|
||||
{
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(5, 11, 0)
|
||||
const int width = fm.horizontalAdvance(tabText);
|
||||
#else
|
||||
const int width = fm.width(tabText);
|
||||
#endif
|
||||
if (width > maxLabelwidth)
|
||||
{
|
||||
maxLabelwidth = width;
|
||||
|
@ -110,6 +118,7 @@ QSize FancyTabBar::TabSizeHint(bool minimum) const
|
|||
}
|
||||
|
||||
}
|
||||
int width = 60 + spacing + 2;
|
||||
int iconHeight = minimum ? 0 : 32;
|
||||
|
||||
return QSize(qMax(width, maxLabelwidth + 4), iconHeight + spacing + fm.height());
|
||||
|
|
|
@ -176,7 +176,11 @@ void VTextGraphicsItem::paint(QPainter *painter, const QStyleOptionGraphicsItem
|
|||
break;
|
||||
}
|
||||
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(5, 11, 0)
|
||||
if (fm.horizontalAdvance(qsText) > iW)
|
||||
#else
|
||||
if (fm.width(qsText) > iW)
|
||||
#endif
|
||||
{
|
||||
qsText = fm.elidedText(qsText, Qt::ElideMiddle, iW);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user