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

QFontMetricsF::maxWidth() return rounded value

    XMLWordPrintable

Details

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

    Description

       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.

      Attachments

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

        Activity

          People

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

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes