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

Diagonal lines with QPainter::DrawLine() paints at wrong coördinates.

    XMLWordPrintable

Details

    • Bug
    • Resolution: Done
    • P2: Important
    • 5.5.0 Beta
    • 5.4.2
    • GUI: Painting
    • fd6a2d1c8ff0488757378080f6003c434fd68de2

    Description

      When drawing a diagonal line using QPainter::DrawLine() with a linewidth of 1, the start and end coördinates are of by one.
      Examples:

      painter.drawLine(2, 7, 6, 1);

      Qt 4.8.5: a line will be drawn from x2, y7 to x6, y1

      This is exactly as advertised in the Qt5 doc: http://qt-project.org/doc/qt-5/coordsys.html

      Qt 5.2.1: a line will be drawn from x1, y7 to x5, y1

      painter.drawLine(10, 10, 16, 4); (a line with an angle of exactly 45 degrees)

      Qt 4.8.5: a line will be drawn from x10, y10 to x16, y4

      Qt 5.2.1: a line will be drawn from x10, y9 to x16, y3

      I provide a small project that demonstrates the problem.
      I also provide some screenshots in PNG and XCF format (can be opened with The Gimp).
      When compiled with Qt 4.8.5, the output of DrawLine() is as expected and as advertised in the Qt5 doc:
      http://qt-project.org/doc/qt-5/coordsys.html

      Attachments

        1. AliasedDrawingPatch.diff
          5 kB
        2. diagonalLine.png
          diagonalLine.png
          24 kB
        3. QPainter_bug_project.tar.gz
          3 kB
        4. Qt487_DSRemote.png
          Qt487_DSRemote.png
          76 kB
        5. Qt487_EDFbrowser.png
          Qt487_EDFbrowser.png
          19 kB
        6. Qt542_DSRemote.png
          Qt542_DSRemote.png
          71 kB
        7. Qt542_EDFbrowser.png
          Qt542_EDFbrowser.png
          17 kB
        8. qtbug38144-no_patch.png
          qtbug38144-no_patch.png
          3 kB
        9. qtbug38144-patched.png
          qtbug38144-patched.png
          3 kB
        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            allan.jensen Allan Sandfeld Jensen
            trino trino
            Votes:
            2 Vote for this issue
            Watchers:
            10 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes