passing coordinate value from c++ source file to qml file
-
i am trying to update the coordinate values used in qml file for showing location on the map through c++ source file.
My c++ source file
@
QQuickView *view = new QQuickView();
view->setsource(Qurl::fromlocalfile(("filepath"));
Qobject *item =view->rootObject();
Item->setproperty("latitude",lat);
Item->setProperty("longitude",lon);where lat and lon are the values which i want to pass to Qml file
i have declared two properties named longitude and latitude for getting values from c++ file
the map center is able to access these lat long values if they are chnaged from source file but marker is not updated according to the chnaged values, is there any better way to pass variables from Qt c++ to Qt Qml? -
Use a separate QObject-derived class and set it as context property.
Other options: