- Qt 6.11
- Qt Positioning
- Interfaces between C++ and QML Code in Qt Positioning
- Qt 6.11.2 Reference Documentation

Positioning (C++) ◦ Android support

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

## Overview

Qt Positioning utilizes two methods to simplify exchange of position data between C++ and QML code.

## Direct mapping

Qt Positioning allow you to pass the following value types from QML to C++, and vice versa:

C++ Class | QML Value Type
--- | ---
QGeoCircle | geoCircle
QGeoCoordinate | geoCoordinate
QGeoPath | geoPath
QGeoPolygon | geoPolygon
QGeoRectangle | geoRectangle
QGeoSatelliteInfo | geoSatelliteInfo
QGeoShape | geoShape

## QVariant Based integration

This section provides information on how to integrate QGeoAddress and QGeoLocation.

### Address - QGeoAddress

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

The following piece of code gets the QGeoAddress object from C++:

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

The following piece of code sets the address property of the QML 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 the property() and setProperty() functions must be used to get and set the `location` property.

The following piece of code gets the QGeoLocation object from C++:

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

The following piece of code sets the location property of the QML object based on a QGeoLocation object from C++:

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

Positioning (C++) ◦ Android support