route QML Value Type | Qt Location | Qt 6.10.3
Description: The route type represents one geographical route.

- Qt 6.10
- Qt Location
- QML Types
- route
- Qt 6.10.3 Reference Documentation

# route QML Value Type

The route type represents one geographical route. More...

Import Statement: | `import QtLocation 6.10`
Since: | QtLocation 5.5

## Properties

- bounds : geoRectangle
- distance : real
- extendedAttributes : Object `(since QtLocation 5.13)`
- legIndex : int
- legs : list<route> `(since QtLocation 5.12)`
- overallRoute : Route
- path : list<coordinate>
- segments : list<routeSegment>
- travelTime : int

## Methods

- int segmentsCount()

## Detailed Description

A route type contains high level information about a route, such as the length the route, the estimated travel time for the route, and enough information to render a basic image of the route on a map.

The QGeoRoute object also contains a list of routeSegment objects which describe subsections of the route in greater detail.

The primary means of acquiring route objects is RouteModel.

## Example

This example shows how to display a route's maneuvers in a ListView:

     import QtQuick
     import QtPositioning
     import QtLocation

     RouteModel {
         id: routeModel
         // model initialization
     }

     ListView {
         id: listview
         anchors.fill: parent
         spacing: 10
         model: routeModel.status == RouteModel.Ready ? routeModel.get(0).segments : null
         visible: model ? true : false
         delegate: Row {
             width: parent.width
             spacing: 10
             property bool hasManeuver : modelData.maneuver && modelData.maneuver.valid
             visible: hasManeuver
             Text { text: (1 + index) + "." }
             Text { text: hasManeuver ? modelData.maneuver.instructionText : "" }
         }
     }

## Property Documentation

bounds : geoRectangle

Read-only property which holds a bounding box which encompasses the entire route.

distance : real

Read-only property which holds distance covered by this route, in meters.

extendedAttributes : Object `[since QtLocation 5.13]`

This property holds the extended attributes of the route and is a map. These attributes are plugin specific, and can be empty.

Consult the plugin documentation for what attributes are supported and how they should be used.

Note, due to limitations of the QQmlPropertyMap, it is not possible to declaratively specify the attributes in QML, assignment of attributes keys and values can only be accomplished by JavaScript.

This property was introduced in QtLocation 5.13.

legIndex : int

Read-only property which holds the index of the leg within the containing route's list of QtLocation::route::legs. The index is -1 if this route is not a leg within an overall route.

See also overallRoute.

legs : list<route> `[since QtLocation 5.12]`

Returns the route legs associated with this route. Route legs are the sub-routes between each two adjacent waypoints. The result may be empty, if this level of detail is not supported by the backend.

This property was introduced in QtLocation 5.12.

overallRoute : Route

Read-only property which holds the route that contains this leg.

path : list<coordinate>

Read-only property which holds the geographical coordinates of this route. Coordinates are listed in the order in which they would be traversed by someone traveling along this segment of the route.

To access individual segments you can use standard list accessors: 'path.length' indicates the number of objects and 'path[index starting from zero]' gives the actual object.

See also QtPositioning::coordinate.

segments : list<routeSegment>

Read-only property which holds the list of routeSegment objects of this route.

To access individual segments you can use standard list accessors: 'segments.length' indicates the number of objects and 'segments[index starting from zero]' gives the actual objects.

See also routeSegment.

travelTime : int

Read-only property which holds the estimated amount of time it will take to traverse this route, in seconds.

## Method Documentation

int segmentsCount()

Returns the number of segments in the route

See also routeSegment.