MapItemView is not updating upon model dataChanged signals



  • 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"
            }
        }
    }
    


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



Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.