Skip to content

Commit

Permalink
avoid warning message for deprecated function
Browse files Browse the repository at this point in the history
/home/kunyi/Allwinner/YFEL/src/lib/QHexView/QHexView.cpp: In constructor ‘QHexView::QHexView(QWidget*)’:
/home/kunyi/Allwinner/YFEL/src/lib/QHexView/QHexView.cpp:29:38: warning: ‘int QFontMetrics::width(QChar) const’ is deprecated: Use QFontMetrics::horizontalAdvance [-Wdeprecated-declarations]
   29 |     m_charWidth = fontMetrics().width(QLatin1Char('9'));
      |                   ~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~
In file included from /usr/include/x86_64-linux-gnu/qt5/QtWidgets/qwidget.h:50,
                 from /usr/include/x86_64-linux-gnu/qt5/QtWidgets/qframe.h:44,
                 from /usr/include/x86_64-linux-gnu/qt5/QtWidgets/qabstractscrollarea.h:44,
                 from /usr/include/x86_64-linux-gnu/qt5/QtWidgets/QAbstractScrollArea:1,
                 from /home/kunyi/Allwinner/YFEL/src/lib/QHexView/QHexView.h:4,
                 from /home/kunyi/Allwinner/YFEL/src/lib/QHexView/QHexView.cpp:1:
/usr/include/x86_64-linux-gnu/qt5/QtGui/qfontmetrics.h:110:9: note: declared here
  110 |     int width(QChar) const;
  • Loading branch information
KunYi committed Aug 4, 2023
1 parent 41b30b8 commit aee7efb
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/lib/QHexView/QHexView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ QHexView::QHexView(QWidget *parent) :
m_pdata(NULL) {
setFont(QFont("Courier", 10));

#if QT_VERSION >= 0x051100
#if QT_VERSION >= QT_VERSION_CHECK(5,11,0)
m_charWidth = fontMetrics().horizontalAdvance(QLatin1Char('9'));
#else
m_charWidth = fontMetrics().width(QLatin1Char('9'));
Expand Down Expand Up @@ -100,7 +100,7 @@ QSize QHexView::fullSize() const {
}

void QHexView::updatePositions() {
#if QT_VERSION >= 0x051100
#if QT_VERSION >= QT_VERSION_CHECK(5,11,0)
m_charWidth = fontMetrics().horizontalAdvance(QLatin1Char('9'));
#else
m_charWidth = fontMetrics().width(QLatin1Char('9'));
Expand Down Expand Up @@ -532,4 +532,4 @@ QByteArray QHexView::DataStorageFile::getData(std::size_t position, std::size_t

std::size_t QHexView::DataStorageFile::size() {
return m_file.size();
}
}

0 comments on commit aee7efb

Please sign in to comment.