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

REGRESSION: QPainter::drawLine() with QPen::FlatCap pen is off-by-one

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Done
    • Icon: P1: Critical P1: Critical
    • 4.8.0
    • 4.8.0
    • GUI: Painting
    • None
    • 49409f612c47f30434aa809e4d2c963f1a6bb88a

      Run the following application with Qt 4.7.x and then Qt 4.8:

      #include <QtGui>
      
      class MyWidget: public QWidget
      {
      public:
          MyWidget(QWidget *parent = 0) : QWidget(parent) {}
      
          void paintEvent(QPaintEvent *)
          {
              QPainter p(this);
      
              QPen pen(Qt::black);
              pen.setCapStyle(Qt::FlatCap);
              p.setPen(pen);
      
              int y = rect().center().y();
              p.drawLine(QPointF(0, y), QPointF(width(), y));
          }
      };
      
      int main(int argc, char **argv)
      {
          QApplication app(argc, argv);
      
          MyWidget w;
          w.resize(100, 100);
          w.show();
      
          return app.exec();
      }
      

      The pixel at 0, y will not be covered with Qt 4.8. This breaks underlines in text, which uses flat caps.

      See screenshot for comparison.

        1. lines-regression.png
          11 kB
          Eskil Abrahamsen Blomfeldt
        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

            laknoll Lars Knoll
            esabraha Eskil Abrahamsen Blomfeldt
            Votes:
            1 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved:

                There are no open Gerrit changes