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

PathCurve documentation example is not working (+fix)

    XMLWordPrintable

Details

    • Bug
    • Resolution: Done
    • P2: Important
    • 5.0.2
    • 5.0.0
    • Documentation
    • None
    • 21c1cfb8674c0af9f52ef57c4fbd47f0bc78546f

    Description

      Hi,

      This link:
      http://qt-project.org/doc/qt-5.0/qtquick/qml-qtquick2-pathcurve.html

      contains this example:

      import QtQuick 2.0
      
      Canvas {
          width: 400; height: 200
      
          Path {
              id: myPath
              startX: 0; startY: 100
      
              PathCurve { x: 75; y: 75 }
              PathCurve { x: 200; y: 150 }
              PathCurve { x: 325; y: 25 }
              PathCurve { x: 400; y: 100 }
          }
      
          onPaint: {
              context.strokeStyle = Qt.rgba(.4,.6,.8);
              context.path = myPath;
              context.stroke();
          }
      }
      

      Which is... flawed!
      This is the working version:

      import QtQuick 2.0
      
      Canvas {
          id: canvas
          width: 400; height: 200
      
          Path {
              id: myPath
              startX: 0; startY: 100
      
              PathCurve { x: 75; y: 75 }
              PathCurve { x: 200; y: 150 }
              PathCurve { x: 325; y: 25 }
              PathCurve { x: 400; y: 100 }
          }
      
          onPaint: {
              var ctx = canvas.getContext('2d');
              ctx.strokeStyle = Qt.rgba(.4,.6,.8);
              ctx.path = myPath;
              ctx.stroke();
          }
      }
      

      Note: please do test out examples if you put them in the documentation. It's "kinda" annoying when i try an example and get run errors...

      Cheers,
      Mark

      Attachments

        For Gerrit Dashboard: QTBUG-29114
        # Subject Branch Project Status CR V

        Activity

          People

            treinio Topi Reiniƶ
            markg85 Mark
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes