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. Canvas Polyline in QML
Forum Updated to NodeBB v4.3 + New Features

Canvas Polyline in QML

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
5 Posts 2 Posters 2.2k Views 1 Watching
  • 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.
  • saitejS Offline
    saitejS Offline
    saitej
    wrote on last edited by
    #1

    Hi

    How to draw a polyline in QML canvas by dynamically adding points to the line path?

    Thanks.

    1 Reply Last reply
    0
    • ? Offline
      ? Offline
      A Former User
      wrote on last edited by A Former User
      #2

      Hi! You need to make multiple calls to lineTo():

      ctx.beginPath()
      for (var i=0; i<pts.length-1; ++i) {
        ctx.moveTo(pts[i].x, pts[i].y)
        ctx.lineTo(pts[i+1].x, pts[i+1].y)
      }
      ctx.stroke()
      
      1 Reply Last reply
      1
      • saitejS Offline
        saitejS Offline
        saitej
        wrote on last edited by
        #3

        @Wieland

        Can canvas be added as a Mapquickitem?

        I am able to add the the canvas successfully on the map but it does not have the mapquickitem properties like onzoom and pan change etc. I am repainting the canvas onzoomlevelchanged , gesture.onPanStarted and gesture.onPanFinished. But the repaint is not so swift and so the lines can be seen not moving with the map. Is there a way to avoid this?

        Note: I am trying to use canvas instead of mappolyline due to bad rendering of the latter and also to add curves to end lines.

        Here is the video demonstrating my problem.

        Thanks

        ? 1 Reply Last reply
        0
        • saitejS saitej

          @Wieland

          Can canvas be added as a Mapquickitem?

          I am able to add the the canvas successfully on the map but it does not have the mapquickitem properties like onzoom and pan change etc. I am repainting the canvas onzoomlevelchanged , gesture.onPanStarted and gesture.onPanFinished. But the repaint is not so swift and so the lines can be seen not moving with the map. Is there a way to avoid this?

          Note: I am trying to use canvas instead of mappolyline due to bad rendering of the latter and also to add curves to end lines.

          Here is the video demonstrating my problem.

          Thanks

          ? Offline
          ? Offline
          A Former User
          wrote on last edited by
          #4

          @saitej said in Canvas Polyline in QML:

          Can canvas be added as a Mapquickitem?

          The manual says:

          The MapQuickItem type displays an arbitrary Qt Quick object on a Map.

          Regarding the performance related things: I don't know.

          saitejS 1 Reply Last reply
          0
          • ? A Former User

            @saitej said in Canvas Polyline in QML:

            Can canvas be added as a Mapquickitem?

            The manual says:

            The MapQuickItem type displays an arbitrary Qt Quick object on a Map.

            Regarding the performance related things: I don't know.

            saitejS Offline
            saitejS Offline
            saitej
            wrote on last edited by
            #5

            @Wieland

            Thanks!! I will give it a shot.

            1 Reply Last reply
            0

            • Login

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