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

QFontMetrics::boundingRect size decreases when string length increases

    XMLWordPrintable

Details

    • Bug
    • Resolution: Done
    • P2: Important
    • 4.7.1
    • 4.6.3
    • GUI: Font handling
    • None
    • Ubuntu 10.04
    • 40b6c1dd9199ac5e0d6a1921b05c11e647d09dca

    Description

      main.cpp
      #include <QtDebug>
      #include <QtGui>
      
      int main(int argc, char *argv[])
      {
        QApplication a(argc, argv);
        QFontMetrics metrics(QFont("Arial", 11));
        qDebug() << metrics.boundingRect("test");
        qDebug() << metrics.boundingRect("test ");
        return a.exec();
      }
      

      On my machine, the output is:
      QRect(-1,-14 26x18)
      QRect(-1,-14 22x18)

      Note that size decreases when the space is added. I could understand it being the same (the space doesn't need any painting room), but decrease? This is causing problem if this bounding rect is used for QPainter::drawText, because the smaller rectangle clips the text.

      Attachments

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

        Activity

          People

            jiang Jiang Jiang
            dmateer Dave Mateer
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes