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

QML Canvas, reset line dash failed

    XMLWordPrintable

Details

    • Linux/X11
    • c31638f16b1fe709dd9df232afb9ab7fac3b231e (qt/qtdeclarative/dev) 9a967bf6a6583099d5593e95e29118139f8be975 (qt/qtdeclarative/6.1) 5fde06d4b7113408cb1edc9a2ca4d8aa5a9884af (qt/qtdeclarative/6.2) 1ec362aa10 (qt/tqtc-qtdeclarative/5.15-opensource)

    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

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

            Dates

              Created:
              Updated:
              Resolved: