Interfaces between C++ and QML Code in Qt Positioning | Qt Positioning 5.4

- Qt 5.4
- Qt Positioning
- Interfaces between C++ and QML Code in Qt Positioning
- Qt 5.4.2 Reference Documentation

# Interfaces between C++ and QML Code in Qt Positioning

### Address - QGeoAddress

The Address.address property is used to provide an interface between C++ and QML code. First a pointer to a Address object must be obtained from C++, then use the property() and setProperty() functions to get and set the `address` property. The following gets the QGeoAddress representing this object from C++:

     QGeoAddress geoAddress = qmlObject->property("address").value<QGeoAddress>();

The following sets the properties of this object based on a QGeoAddress object from C++:

    qmlObject->setProperty("address", QVariant::fromValue(geoAddress));

### Location - QGeoLocation

The Location.location property is used to provide an interface between C++ and QML code. First a pointer to a Location object must be obtained from C++, then use the property() and setProperty() functions to get and set the `location` property. The following gets the QGeoLocation representing this object from C++:

    QGeoLocation geoLocation = qmlObject->property("location").value<QGeoLocation>();

The following sets the properties of this object based on a QGeoLocation object from C++:

    qmlObject->setProperty("location", QVariant::fromValue(geoLocation));