diff --git a/src/frontends/qt/qt_helpers.cpp b/src/frontends/qt/qt_helpers.cpp index 2e5e7da9c5..fc1f961b5a 100644 --- a/src/frontends/qt/qt_helpers.cpp +++ b/src/frontends/qt/qt_helpers.cpp @@ -703,7 +703,11 @@ QString formatToolTip(QString text, int em) text = Qt::convertFromPlainText(text, Qt::WhiteSpaceNormal); // Compute desired width in pixels QFont const font = QToolTip::font(); +#if (QT_VERSION >= QT_VERSION_CHECK(5, 11, 0)) + int const px_width = em * QFontMetrics(font).horizontalAdvance("M"); +#else int const px_width = em * QFontMetrics(font).width("M"); +#endif // Determine the ideal width of the tooltip QTextDocument td(""); td.setHtml(text);