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

QML Canvas, reset line dash failed

    XMLWordPrintable

    Details

      Description

      Reset line dash pattern not working in Canvas

      import QtQuick 2.12
      import QtQuick.Window 2.12
      
      Window {
          width: 640
          height: 480
          visible: true
      
          Canvas {
              anchors.fill: parent
              onPaint: {
                  var ctx = getContext("2d")
                  ctx.lineWidth = 3
      
                  ctx.save()
                  ctx.setLineDash([3, 5])
                  ctx.beginPath()
                  ctx.moveTo(0, 0)
                  ctx.lineTo(250, 250)
                  ctx.stroke()
                  ctx.restore()
      
                  ctx.save()
                  ctx.setLineDash([]) //no effect
                  ctx.beginPath()
                  ctx.moveTo(50, 0)
                  ctx.lineTo(300, 250)
                  ctx.stroke()
                  ctx.restore()
              }
          }
      }
      

        Attachments

        1. dashline.png
          dashline.png
          5 kB
        2. expected.png
          expected.png
          2 kB
        3. main.qml
          0.7 kB
        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

          Activity

            People

            Assignee:
            andysh Andy Shaw
            Reporter:
            lbaudouin Leo Baudouin
            Votes:
            5 Vote for this issue
            Watchers:
            6 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved: