title: How to change property of QML item from c++
body: <p>I am writing a small QT(5.12) application in C++, which will be moving center of QMap every second. I am trying to update the coordinates so the center will refresh, but after debugging it, it's always staying the same (original value). That's my first attempt with QML, so I am helping myself with the link bellow, but apparently I am not doing something right.<br><br>
  <a href="https://doc.qt.io/qt-5/qtqml-cppintegration-interactqmlfromcpp.html" rel="nofollow noreferrer">https://doc.qt.io/qt-5/qtqml-cppintegration-interactqmlfromcpp.html</a></p>
  
  <p>Update function called every second by timer</p>
  
  <pre><code>#include &lt;QQmlEngine&gt;
  #include &lt;QQmlComponent&gt;
  
  void MainWindow::UpdateCoordinates()
  {
      float LATDEGM = (60 * 1853.181);
      float DEG2RAD = (PI / 180.0);
  
      QString speedData = ui-&gt;sboxSpeed-&gt;text();
      bool ok;
      AirSpeed = speedData.toInt(&amp;ok);
      AirCourse = (AirCourse + 360) % 360;
  
      Dx = AirSpeed * sin((float)AirCourse * DEG2RAD);
      Dy = AirSpeed * cos((float)AirCourse * DEG2RAD);
  
      QString dat = ui-&gt;txtLatitude-&gt;text();
      Lat = dat.toDouble();
      QString dat2 = ui-&gt;txtLongtitude-&gt;text();
      Lon = dat2.toDouble();
  
      Dx /= 3.6;
      Dy /= 3.6;
  
      Lat += Dy / LATDEGM;
      Lon += Dx / (LATDEGM * cos(Lat * DEG2RAD));
  
      ui-&gt;txtLatitude-&gt;setText(QString::number(Lat));
      ui-&gt;txtLongtitude-&gt;setText(QString::number(Lon));
  
      // Using QQmlComponent
      QQmlEngine engine;
      QQmlComponent component(&amp;engine,QUrl(QStringLiteral("qrc:/Map.qml")));
      QObject *object = component.create();
      QObject *map = object-&gt;children().at(1);
  
      if (map)
      {
          map-&gt;setProperty("newLatitude", Lat);
          map-&gt;setProperty("newLongitude", Lon);
          std::cout &lt;&lt; "Property value:" &lt;&lt; map-&gt;property("latitude").toDouble() &lt;&lt; std::endl;
          std::cout &lt;&lt; "Property value:" &lt;&lt; map-&gt;property("longitude").toDouble() &lt;&lt; std::endl;
      }
  }
  </code></pre>
  
  <p>Map.qml</p>
  
  <pre><code>import QtQuick 2.0
  import QtQuick.Window 2.0
  import QtLocation 5.6
  import QtPositioning 5.6
  
  Item{
      id: itemControl
      width: 512
      height: 512
      visible: true
  
      property alias newLongitude : map.longitude;
      property alias newLatitude : map.latitude;
  
      Plugin {
          id: mapPlugin
          name: "esri"
      }
  
      Map {
          id: map
          anchors.fill: parent
          maximumZoomLevel: 15
          minimumZoomLevel: 15
          width: 512
          height: 512
          plugin: mapPlugin
          center {
              property real latitude: 45.5082047
              property real longitude: 13.5757492
          }
          zoomLevel: 14
      }
  }
  </code></pre>