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. MapItemView is not updating upon model dataChanged signals
Forum Updated to NodeBB v4.3 + New Features

MapItemView is not updating upon model dataChanged signals

Scheduled Pinned Locked Moved QML and Qt Quick
mapitemviewlocationqmlqabstractitemmodatachanged
2 Posts 1 Posters 2.1k 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.
  • C Offline
    C Offline
    Charby
    wrote on 15 Jul 2015, 08:13 last edited by Charby
    #1

    I can't get having a MapItemView updated whenever data are changed inside the model.
    The MapItemView is well behaving when a new entry is added to the model but it is not reflecting the changes when an existing entry has been modified.

    The model I have used is a QAbstractListModel based model. The model is working correctly when used together with a ListView : every changes in the model (new entry or modification of an existing entry) are showed in the ListView.
    I first experienced this with Qt 5.4 but it is the same with Qt5.5.

    To demonstrate my issue, please find below a small example with a MapItemView and a ListModel (i.o a C++ model). What does I miss ?

    import QtQuick 2.4
    import QtQuick.Window 2.2
    import QtLocation 5.3
    import QtPositioning 5.0
    
    Window {
        visible: true
        width : 1024
        height:768
    
        Map {
           id: map
           anchors.fill: parent
           anchors.margins: 50
           plugin: Plugin{ name:"osm";}
           center: QtPositioning.coordinate(47.1, -1.6)
           zoomLevel: map.maximumZoomLevel
    
    
           MapItemView{
               id:mapItemView
               model: dummyModel
    
               delegate: MapQuickItem {
                  //anchorPoint:
                  id:delegateMQI
                  rotation: model.Azimuth
                  sourceItem: Rectangle{
                      id:defaultDelegate
                      width:32
                      height:32
                      radius:16
                      opacity: 0.6
                      rotation:Azimuth
                      color:Color
    
                      Text{
                          text: Azimuth
                          anchors.centerIn : parent
                      }
    
                  }
                  coordinate: QtPositioning.coordinate(Latitude,Longitude)
              }
    
           }
           MouseArea{
               anchors.fill: parent
               onClicked:
               {
                   //Modify an item
                   var newAzim = Math.random()*360;
                   dummyModel.setProperty(0, "Azimuth", newAzim);
                   //Check modification
                   console.log("Azim:" + dummyModel.get(0).Azimuth );
                   dummyModel.setProperty(0, "Color", "blue");
    
                   //add a new item
                   dummyModel.append({"Latitude": 47.05 + Math.random() *0.1, "Longitude":-1.65 + Math.random() *0.1, "Azimuth":0, "Color":"red"})
                   console.log("Nb item:" + dummyModel.count );
    
                   map.update();
                   map.fitViewportToMapItems();
    
               }
           }
        }
        ListModel{
            id:dummyModel
            ListElement {
                Latitude: 47.1
                Longitude: -1.6
                Azimuth: 10.0
                Color:"red"
            }
        }
    }
    
    1 Reply Last reply
    0
    • C Offline
      C Offline
      Charby
      wrote on 21 Jul 2015, 07:49 last edited by
      #2

      Has any one experienced the same problem ? Any idea of a possible workaround ?
      Thanks for your help.

      1 Reply Last reply
      0

      2/2

      21 Jul 2015, 07:49

      • Login

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