Qt5: 'int QFontMetrics::width' is deprecated since Qt 5.11: Use QFontMetrics::horizontalAdvance [-Wdeprecated-declarations]

This commit is contained in:
wmayer
2020-06-10 12:27:50 +02:00
committed by wwmayer
parent db3f9008c0
commit 1ee3d79d7c
21 changed files with 107 additions and 29 deletions

View File

@@ -61,6 +61,7 @@
#include <Gui/Utilities.h>
#include <Gui/View3DInventor.h>
#include <Gui/View3DInventorViewer.h>
#include <Gui/Tools.h>
#include <App/Document.h>
#include <App/DocumentObject.h>
@@ -408,7 +409,7 @@ void FaceColors::updatePanel()
int maxWidth = d->ui->labelElement->width();
QFontMetrics fm(d->ui->labelElement->font());
if (fm.width(faces) > maxWidth) {
if (Gui::QtTools::horizontalAdvance(fm, faces) > maxWidth) {
faces = fm.elidedText(faces, Qt::ElideMiddle, maxWidth);
}

View File

@@ -44,6 +44,7 @@
#include <Base/UnitsApi.h>
#include <Gui/Selection.h>
#include <Gui/Command.h>
#include <Gui/Tools.h>
#include <Mod/PartDesign/App/FeatureChamfer.h>
#include <Mod/PartDesign/App/Body.h>
#include <Mod/Sketcher/App/SketchObject.h>
@@ -131,10 +132,10 @@ void TaskChamferParameters::setUpUI(PartDesign::Chamfer* pcChamfer)
ui->stackedWidget->setFixedHeight(ui->chamferSize2->sizeHint().height());
QFontMetrics fm(ui->typeLabel->font());
int minWidth = fm.width(ui->typeLabel->text());
minWidth = std::max<int>(minWidth, fm.width(ui->sizeLabel->text()));
minWidth = std::max<int>(minWidth, fm.width(ui->size2Label->text()));
minWidth = std::max<int>(minWidth, fm.width(ui->angleLabel->text()));
int minWidth = Gui::QtTools::horizontalAdvance(fm, ui->typeLabel->text());
minWidth = std::max<int>(minWidth, Gui::QtTools::horizontalAdvance(fm, ui->sizeLabel->text()));
minWidth = std::max<int>(minWidth, Gui::QtTools::horizontalAdvance(fm, ui->size2Label->text()));
minWidth = std::max<int>(minWidth, Gui::QtTools::horizontalAdvance(fm, ui->angleLabel->text()));
minWidth = minWidth + 5; //spacing
ui->typeLabel->setMinimumWidth(minWidth);
ui->sizeLabel->setMinimumWidth(minWidth);

View File

@@ -56,6 +56,7 @@
#include "SoDatumLabel.h"
#include <Gui/BitmapFactory.h>
#include <Gui/Tools.h>
#define ZCONSTR 0.006f
@@ -116,7 +117,7 @@ void SoDatumLabel::drawImage()
QFontMetrics fm(font);
QString str = QString::fromUtf8(s[0].getString());
int w = fm.width(str);
int w = Gui::QtTools::horizontalAdvance(fm, str);
int h = fm.height();
// No Valid text

View File

@@ -94,6 +94,7 @@
#include <Gui/CommandT.h>
#include <Gui/Control.h>
#include <Gui/Selection.h>
#include <Gui/Tools.h>
#include <Gui/Utilities.h>
#include <Gui/MainWindow.h>
#include <Gui/MenuManager.h>
@@ -3471,7 +3472,7 @@ QImage ViewProviderSketch::renderConstrIcon(const QString &type,
boundingBoxes->push_back(labelBB);
}
cursorOffset += qfm.width(labelStr);
cursorOffset += Gui::QtTools::horizontalAdvance(qfm, labelStr);
}
}

View File

@@ -46,6 +46,7 @@
#include <Gui/Command.h>
#include <Gui/Application.h>
#include <Gui/Document.h>
#include <Gui/Tools.h>
#include <Gui/ViewProvider.h>
#include "Rez.h"
@@ -719,7 +720,7 @@ int QGIView::calculateFontPixelSize(double sizeInMillimetres)
int QGIView::calculateFontPixelWidth(const QFont &font)
{
// Return the width of digit 0, most likely the most wide digit
return QFontMetrics(font).width(QChar::fromLatin1('0'));
return Gui::QtTools::horizontalAdvance(QFontMetrics(font), QChar::fromLatin1('0'));
}
const double QGIView::DefaultFontSizeInMM = 5.0;

View File

@@ -48,6 +48,7 @@
#include <Base/Parameter.h>
#include <Gui/Command.h>
#include <Gui/Control.h>
#include <Gui/Tools.h>
#include <string>
#include <Mod/TechDraw/App/DrawPage.h>
@@ -444,7 +445,7 @@ void QGIViewBalloon::updateBalloon(bool obtuse)
int pos = labelText.indexOf(QString::fromUtf8("|"));
labelText.replace(pos, 1, QString::fromUtf8(" "));
QFontMetrics fm(balloonLabel->getFont());
balloonLabel->seps.push_back(fm.width((labelText.left(pos + 2))));
balloonLabel->seps.push_back(Gui::QtTools::horizontalAdvance(fm, labelText.left(pos + 2)));
balloonLabel->verticalSep = true;
}
}