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

Inconsistent QPainter behaviour

    XMLWordPrintable

Details

    • Bug
    • Resolution: Done
    • P4: Low
    • 4.7.0
    • 4.4.1
    • GUI: Painting
    • None
    • c28efecdcfdd5fa0049bf482cb102814338c0d99

    Description

      Running the test code below will show that the behavior of flat rects varies for Arcs and Ellipses.

      For flat arcs, QPainter draws what appears to be a line which is the correct behavior. This is because the bounding rect for a flat rect is actually the flat rect adjusted in each coordinate direction by line width / 2.0. Therefore, the bounding rect is non-flat and accommodates the "mathematical" line exactly as it would be painted on a device. This also coincides with the definition of bounding rect painting behaviour
      in QGraphicsItem.

      For flat ellipses, QPainter does not draw what appears to be a line which is incorrect behavior.

      Test code:
      //---------------------------------------------------------
      #include <QtGui>

      class MyWidget : public QWidget
      {
      void paintEvent(QPaintEvent * event)

      { QPainter painter(this); QRect rect1(10, 10, 100, 100); painter.drawArc(rect1, 0, 180 * 16); QRect rect2(10, 70, 100, 0); painter.drawArc(rect2, 0, 180 * 16); QRect rect3(10, 80, 100, 100); painter.drawEllipse(rect3); QRect rect4(10, 190, 100, 0); painter.drawEllipse(rect4); }

      };

      int main(int argc, char * argv[])
      {
      QApplication app(argc, argv);
      MyWidget widget;
      widget.setGeometry(0, 0, 120, 200);
      widget.show();
      return app.exec();
      }
      //---------------------------------------------------------

      Attachments

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

        Activity

          People

            rodal Samuel Rødal
            admin Administrator
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes