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

QPainter::drawEllipse with thick pens

    XMLWordPrintable

Details

    • Bug
    • Resolution: Duplicate
    • Not Evaluated
    • None
    • 4.5.3
    • GUI: Painting
    • None

    Description

      In several situations QPainter::drawEllipse paints an invalid ellipse for thick pens. The situation depends on the paint engine or attributes like antialiasing and alpha value ... . You can see the mismatch easily with the code below on a X11 system. (screenshot is attached). The first circle is painted correctly while the second one is wrong. ( Started with -graphicssystem raster both circles are wrong. ) The bug happens with Qt 4.5.3 and Qt 4.6-beta1..

      #include <QApplication>
      #include <QWidget>
      #include <QPainter>

      class MyWidget: public QWidget
      {
      public:
      MyWidget(QWidget *parent = NULL):
      QWidget(parent)

      { const int m = 20; setContentsMargins(m, m, m, m); }

      protected:
      virtual void paintEvent(QPaintEvent *)

      { double w = qMin(contentsRect().width(), contentsRect().height()); const double pw = w * 0.45; w -= pw; QRectF r(0, 0, w, w); r.moveCenter(contentsRect().center()); QPainter painter(this); // paint circle painter.setPen(QPen(Qt::black, pw)); painter.drawEllipse(r); // paint bad circle QColor c(Qt::white); c.setAlpha(100); QPen pen(c, pw); painter.setPen(pen); painter.drawEllipse(r); }

      };

      int main(int argc, char **argv)
      {
      QApplication a(argc, argv);

      MyWidget w;
      w.resize(600, 600);
      w.show();

      return a.exec();
      }

      Attachments

        1. badcircle.png
          6 kB
          Uwe Rathmann

        Issue Links

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

          Activity

            People

              sletta Gunnar Sletta
              uwe Uwe Rathmann
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Gerrit Reviews

                  There are no open Gerrit changes