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. Trouble with MapPolyLine and ListModel

Trouble with MapPolyLine and ListModel

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
3 Posts 2 Posters 1.3k 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.
  • M Offline
    M Offline
    Mikkie
    wrote on last edited by
    #1

    I have a ListModel with some coordinates. When I assign this model to the "path" property of the MapPolyLine, no line displays. I can use the addCoordinate to add points manually and that does draw the line. The code below is inside my Map{}.

    Pointers would be welcome, perhaps also pointer to good book on QML that would explain/stop problems like this.

        ListModel
        {
            id: assetsPolylineList
            ListElement
            {
                latitude: -28.9
                longitude: 25.1
            }
            ListElement
            {
                latitude: -28.2
                longitude: 25.3
            }
            ListElement
            {
                latitude: -28.4
                longitude: 25.5
            }
            ListElement
            {
                latitude: -28.6
                longitude: 25.7
            }
        }
        
        MapPolyline
        {
            id: assetsPolyline
            line.color: "red"
            line.width: 5
            visible : true
            path : assetsPolylineList
        }
    
    1 Reply Last reply
    0
    • Pablo J. RoginaP Offline
      Pablo J. RoginaP Offline
      Pablo J. Rogina
      wrote on last edited by
      #2

      @Mikkie I guess you need to use a QML list not a ListModel
      In addition, why you cannot specify the list directly for the path property as shown here?

      Upvote the answer(s) that helped you solve the issue
      Use "Topic Tools" button to mark your post as Solved
      Add screenshots via postimage.org
      Don't ask support requests via chat/PM. Please use the forum so others can benefit from the solution in the future

      1 Reply Last reply
      1
      • Pablo J. RoginaP Offline
        Pablo J. RoginaP Offline
        Pablo J. Rogina
        wrote on last edited by
        #3

        @Mikkie UPDATE: I was able to play with some code in order to get a simple QML list from the ListModel. Here's a snippet of my working code:

            Map {
                id: map
                anchors.fill: parent
                plugin: mapPlugin
                center: QtPositioning.coordinate(-28.2, 25.3)
                zoomLevel: 8
                function assetsPolylineListAsList() {
                    var list = []
                    for(var i = 0; i < assetsPolylineList.count; ++i) {
                        list.push(
                            {
                                latitude: assetsPolylineList.get(i).latitude,
                                longitude: assetsPolylineList.get(i).longitude
                            }
                        );
                    }
                    return list
                }
                MapPolyline
                {
                    id: assetsPolyline
                    line.color: "blue"
                    line.width: 3
                    visible : true
                    path : map.assetsPolylineListAsList()
                }
        

        Upvote the answer(s) that helped you solve the issue
        Use "Topic Tools" button to mark your post as Solved
        Add screenshots via postimage.org
        Don't ask support requests via chat/PM. Please use the forum so others can benefit from the solution in the future

        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