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

QPainter::drawPoints draws line segments instead of points

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: P3: Somewhat important P3: Somewhat important
    • None
    • 4.8.6, 5.5.1, 5.10.1
    • GUI: Painting
    • None
    • Linux/X11

      The following code results in a 3x18 pixels dash being drawn instead of a 3x3 dot:

      #include <QPainter>
      #include <QImage>
      
      int main()
      {
          const int w=1000, h=1000;
          QImage img(w, h, QImage::Format_RGBX8888);
          {
              QPainter p(&img);
              p.fillRect(0,0,w,h,Qt::black);
              p.scale(w,h);
              p.setPen(QPen(Qt::red, 3./w, Qt::SolidLine, Qt::RoundCap));
              p.drawPoint(QPointF(0.1,0.1));
          }
          img.save("test.png");
      }
      

      Apparently, this is due to the fact that QPaintEngineEx::drawPoints renders points as line segments of length 1/63., without any attempts to adjust the amount of this shift in X direction according to current scale (the one set by QPainter::scale).

      So, either QPaintEngineEx::drawPoints should be fixed to take scale into account, or the documentation for QPainter::drawPoints should be updated to mention this peculiarity.

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

            vgt Eirik Aavitsland
            10110111 Ruslan Kabatsayev
            Votes:
            3 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:

                There are no open Gerrit changes