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

QML Canvas wrong length of drawing lines

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Not Evaluated
    • Resolution: Invalid
    • Affects Version/s: 5.1.0 , 5.1.1, 5.2.0 Beta1
    • Fix Version/s: None
    • Labels:
    • Environment:
      Windows7+ Qt5.1.0 or Qt5.1.1 or Qt5.2.0beta1

      Description

      Drawing a vertical line or horizontal line in Canvas, the canvas will lengthen the size of the line if next point goes back.
      eg.

      import QtQuick 2.0
      
      Item {
          Canvas {
              id: canvas
              smooth: true
              width: 800; height: 600
      
              onPaint: {
                  var ctx = canvas.getContext('2d');
                  ctx.clearRect(0, 0, canvas.width, canvas.height);
                  ctx.rotate(canvas.rotate);
                  ctx.lineWidth = 5;
                  ctx.strokeStyle = ctx.createPattern("red", Qt.SolidPattern);
      
                  ctx.beginPath()
                  ctx.moveTo(10, 10)
                  ctx.lineTo(30, 10)
                  ctx.stroke()
      
                  ctx.beginPath()
                  ctx.moveTo(10, 20)
                  ctx.lineTo(30, 20)
                  ctx.lineTo(20, 20) //goes back 10 horizontally, and the line will be resized
                  ctx.stroke()
      
                  ctx.restore()
              } //end of onPaint
          } //end of Canvas
      }
      

      the lengths of the two lines should be same, but they are not.
      the same problem also happens for vertical lines.
      please check the screen shot(in Attachment)

        Attachments

        1. Capture.PNG
          7 kB
          realfan
        2. main.qml
          0.7 kB
          realfan
        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

          Activity

            People

            Assignee:
            sletta Gunnar Sletta
            Reporter:
            realfan realfan
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved:

                Gerrit Reviews

                There are no open Gerrit changes