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

QPainter::drawEllipse with thick pens

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Not Evaluated
    • Resolution: Duplicate
    • Affects Version/s: 4.5.3
    • Fix Version/s: None
    • Component/s: GUI: Painting
    • Labels:
      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

          Issue Links

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

            Activity

              People

              Assignee:
              sletta Gunnar Sletta
              Reporter:
              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