Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-73458

QFontMetricsF::maxWidth() return rounded value

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Not Evaluated Not Evaluated
    • 5.10
    • 5.11.0
    • GUI: Font handling
    • None
    • Ubuntu 18.04.1 LTS
    • Linux/X11
    • ee2ad9df701b27790e2ab72e99111d255fde42ed

       I create project with default settings.

      Source code of the project below.

      #include <QApplication>
      #include <QDebug>
      #include <QFontMetrics>
      int main(int argc, char *argv[])
      {
          QApplication app(argc, argv);
          QFont font;
          font.fromString("Monospace,14");
          QFontMetricsF fm(font);
          qDebug() << "maxWidth    : " << fm.maxWidth();
          qDebug() << "widht of 'W': " << fm.width('W');
          return 0;
      }
      

      results: 

      maxWidth    :  11
      widht of 'W':  11.4375
      

      According to documentation maxWidth method returns the width of the widest character in the font. The type of returning value is qreal. And it seems to me that in this example maxWidth should return something as 11.4375.

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

            esabraha Eskil Abrahamsen Blomfeldt
            poljak181 PVA PVA
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved:

                There are no open Gerrit changes