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;
|
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)
|
if (fm.width(qsText) > dW)
|
||||||
|
#endif
|
||||||
{
|
{
|
||||||
qsText = fm.elidedText(qsText, Qt::ElideMiddle, static_cast<int>(dW));
|
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)
|
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;
|
dX = (dW - fm.width(qsText))/2;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
#if QT_VERSION >= QT_VERSION_CHECK(5, 11, 0)
|
||||||
|
dX = dW - fm.horizontalAdvance(qsText);
|
||||||
|
#else
|
||||||
dX = dW - fm.width(qsText);
|
dX = dW - fm.width(qsText);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
// set up the rotation around top-left corner matrix
|
// 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.setBold(tl.m_bold);
|
||||||
fnt.setItalic(tl.m_italic);
|
fnt.setItalic(tl.m_italic);
|
||||||
QFontMetrics fm(fnt);
|
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);
|
const int iTW = fm.width(tl.m_qsText);
|
||||||
|
#endif
|
||||||
if (iTW > iMaxLen)
|
if (iTW > iMaxLen)
|
||||||
{
|
{
|
||||||
iMaxLen = iTW;
|
iMaxLen = iTW;
|
||||||
|
@ -450,7 +454,11 @@ void VTextManager::FitFontSize(qreal fW, qreal fH)
|
||||||
--iFS;
|
--iFS;
|
||||||
fnt.setPixelSize(iFS + maxLine.m_iFontSize);
|
fnt.setPixelSize(iFS + maxLine.m_iFontSize);
|
||||||
QFontMetrics fm(fnt);
|
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);
|
lineLength = fm.width(maxLine.m_qsText);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
while (lineLength > fW && iFS > MIN_FONT_SIZE);
|
while (lineLength > fW && iFS > MIN_FONT_SIZE);
|
||||||
}
|
}
|
||||||
|
|
|
@ -78,7 +78,7 @@ QSize FancyTabBar::TabSizeHint(bool minimum) const
|
||||||
boldFont.setBold(true);
|
boldFont.setBold(true);
|
||||||
QFontMetrics fm(boldFont);
|
QFontMetrics fm(boldFont);
|
||||||
int spacing = 8;
|
int spacing = 8;
|
||||||
int width = 60 + spacing + 2;
|
|
||||||
int maxLabelwidth = 0;
|
int maxLabelwidth = 0;
|
||||||
for (int tab=0 ; tab<Count() ;++tab)
|
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;
|
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);
|
const int width = fm.width(sentence);
|
||||||
|
#endif
|
||||||
if (maxLabelwidth < width)
|
if (maxLabelwidth < width)
|
||||||
{
|
{
|
||||||
maxLabelwidth = width;
|
maxLabelwidth = width;
|
||||||
|
@ -102,7 +106,11 @@ QSize FancyTabBar::TabSizeHint(bool minimum) const
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
#if QT_VERSION >= QT_VERSION_CHECK(5, 11, 0)
|
||||||
|
const int width = fm.horizontalAdvance(tabText);
|
||||||
|
#else
|
||||||
const int width = fm.width(tabText);
|
const int width = fm.width(tabText);
|
||||||
|
#endif
|
||||||
if (width > maxLabelwidth)
|
if (width > maxLabelwidth)
|
||||||
{
|
{
|
||||||
maxLabelwidth = width;
|
maxLabelwidth = width;
|
||||||
|
@ -110,6 +118,7 @@ QSize FancyTabBar::TabSizeHint(bool minimum) const
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
int width = 60 + spacing + 2;
|
||||||
int iconHeight = minimum ? 0 : 32;
|
int iconHeight = minimum ? 0 : 32;
|
||||||
|
|
||||||
return QSize(qMax(width, maxLabelwidth + 4), iconHeight + spacing + fm.height());
|
return QSize(qMax(width, maxLabelwidth + 4), iconHeight + spacing + fm.height());
|
||||||
|
|
|
@ -176,7 +176,11 @@ void VTextGraphicsItem::paint(QPainter *painter, const QStyleOptionGraphicsItem
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if QT_VERSION >= QT_VERSION_CHECK(5, 11, 0)
|
||||||
|
if (fm.horizontalAdvance(qsText) > iW)
|
||||||
|
#else
|
||||||
if (fm.width(qsText) > iW)
|
if (fm.width(qsText) > iW)
|
||||||
|
#endif
|
||||||
{
|
{
|
||||||
qsText = fm.elidedText(qsText, Qt::ElideMiddle, iW);
|
qsText = fm.elidedText(qsText, Qt::ElideMiddle, iW);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user