Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. Reverse the path of PathInterpolator
Forum Updated to NodeBB v4.3 + New Features

Reverse the path of PathInterpolator

Scheduled Pinned Locked Moved Solved QML and Qt Quick
2 Posts 1 Posters 152 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • MarkkyboyM Offline
    MarkkyboyM Offline
    Markkyboy
    wrote on last edited by Markkyboy
    #1

    The code below produces a candy cane shaped path with an orange indicator at the right hand end of the line ( see first image), this means "Progress" reports as 0.0

    I'd like the indicator to start the other end of the path at the bottom of the arc( see second image ), this means "Progress" reports as 1.0, but I would like Progress to be 0.0 at the start.

    The indicator will eventually be animated to simulate a rev counter.

    PathInterpolator {
        id: motionPath
        path: Path {
            id: progressPath
            startX: 1700
            startY: 360
            PathLine { x: 420; y: 360 }
            PathArc { x: 420; y: 760; radiusX: 1; radiusY: 1; direction: PathArc.Counterclockwise }
        }
    }
    Rectangle {
        id: needle
        width: 20
        height: 200
        color: "orange"
        x: motionPath.x
        y: motionPath.y
        rotation: motionPath.angle
        transformOrigin: Item.TopLeft
    }
    Canvas {
        id: candyCane
        anchors.fill: parent
        onPaint: {
            var ctx = getContext("2d");
            ctx.strokeStyle = "red"
            ctx.path = progressPath;
            ctx.lineWidth = 4;
            ctx.stroke();
        }
        onVisibleChanged: requestPaint()
    }
    

    right-end.png

    left-hand.png

    Don't just sit there standing around, pick up a shovel and sweep up!

    I live by the sea, not in it.

    1 Reply Last reply
    0
    • MarkkyboyM Offline
      MarkkyboyM Offline
      Markkyboy
      wrote on last edited by
      #2

      I solved this after a few attempts using ChatGPT, not what I wanted ultimately, but manually I really struggled with this.

      Don't just sit there standing around, pick up a shovel and sweep up!

      I live by the sea, not in it.

      1 Reply Last reply
      0
      • MarkkyboyM Markkyboy has marked this topic as solved on

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved