diff options
author | japm48 <japm48@users.noreply.github.com> | 2020-05-02 03:10:13 +0200 |
---|---|---|
committer | Derek Kozel <derek.kozel@gmail.com> | 2020-05-26 15:14:20 +0100 |
commit | aaa38ebab7f903c45999390b9a49311cc32bc9ef (patch) | |
tree | bb1273c1b30eb9382b75b03a9a87b93b942c04c2 | |
parent | bc0c43aad12abb83798b25d44842ab043703f686 (diff) |
qtgui: fix deprecated use of QFontMetrics::width
Replaced with horizontalAdvance (requires Qt >=5.11).
-rw-r--r-- | gr-qtgui/lib/DisplayPlot.cc | 7 | ||||
-rw-r--r-- | gr-qtgui/lib/edit_box_msg_impl.cc | 4 |
2 files changed, 10 insertions, 1 deletions
diff --git a/gr-qtgui/lib/DisplayPlot.cc b/gr-qtgui/lib/DisplayPlot.cc index e982c855e6..8c115c8b8c 100644 --- a/gr-qtgui/lib/DisplayPlot.cc +++ b/gr-qtgui/lib/DisplayPlot.cc @@ -71,7 +71,12 @@ DisplayPlot::DisplayPlot(int nplots, QWidget* parent) const QFontMetrics fm(axisWidget(QwtPlot::yLeft)->font()); QwtScaleDraw* sd = axisScaleDraw(QwtPlot::yLeft); - sd->setMinimumExtent(fm.width("100.00")); +#if (QT_VERSION >= QT_VERSION_CHECK(5, 11, 0)) + int min_ext = fm.horizontalAdvance("100.00"); +#else + int min_ext = fm.width("100.00"); +#endif + sd->setMinimumExtent(min_ext); QwtLegend* legendDisplay = new QwtLegend(this); diff --git a/gr-qtgui/lib/edit_box_msg_impl.cc b/gr-qtgui/lib/edit_box_msg_impl.cc index 7bb41b9a0c..cfc19201be 100644 --- a/gr-qtgui/lib/edit_box_msg_impl.cc +++ b/gr-qtgui/lib/edit_box_msg_impl.cc @@ -88,7 +88,11 @@ edit_box_msg_impl::edit_box_msg_impl(data_type_t type, d_key->setEnabled(false); QFontMetrics fm = d_key->fontMetrics(); +#if (QT_VERSION >= QT_VERSION_CHECK(5, 11, 0)) + int width = 15 + fm.horizontalAdvance(key_text); +#else int width = 15 + fm.width(key_text); +#endif d_key->setFixedWidth(width); |