RouteModelThe RouteModel element provides access to routes. More... Inherits QtObject This type was introduced in Qt Location 5.0. Properties
MethodsDetailed DescriptionThe RouteModel element is used as part of a model/view grouping to retrieve geographic routes from a backend provider. Routes include data about driving directions between two points, walking directions with multiple waypoints, and various other similar concepts. It functions much like other Model elements in QML (see for example ListModel and XmlListModel), and interacts with views such as MapItemView, and ListView. Like Map and GeocodeModel, all the data for a RouteModel to work comes from a services plugin. This is contained in the plugin property, and this must be set before the RouteModel can do any useful work. Once the plugin is set, create a RouteQuery with the appropriate waypoints and other settings, and set the RouteModel's query property. If autoUpdate is enabled, the update will being automatically. Otherwise, the update method may be used. By default, autoUpdate is disabled. The data stored and returned in the RouteModel consists of Route elements, as a list with the role name "routeData". See the documentation for Route for further details on its structure and contents. Example UsageThe following snippet is two-part, showing firstly the declaration of elements, and secondly a short piece of procedural code using it. We set the routeModel's autoUpdate property to false, and call update once the query is set up, to avoid useless extra requests halfway through the set up of the query. Plugin {
id: aPlugin
}
RouteQuery {
id: aQuery
}
RouteModel {
id: routeModel
plugin: aPlugin
query: aQuery
autoUpdate: false
}
{ aQuery.addWaypoint(...) aQuery.addWaypoint(...) aQuery.travelModes = ... routeModel.update() } Property DocumentationThis property controls whether the Model automatically updates in response to changes in its attached RouteQuery. The default value of this property is false. If setting this value to 'true', note that any change at all in the RouteQuery object set in the query property will trigger a new request to be sent. If you are adjusting many properties of the RouteQuery with autoUpdate enabled, this can generate large numbers of useless (and later discarded) requests. This property holds how many routes the model currently has. Amongst other uses, you can use this value when accessing routes via the QtLocation5::RouteModel::get -method. This read-only property holds the latest error value of the routing request.
This read-only property holds the textual presentation of latest routing error. If no error has occurred or the model has been reset, an empty string is returned. An empty string may also be returned if an error occurred which has no associated textual representation. This property holds the plugin that providers the actual routing service. Note that all plugins do not necessarily provide routing (could for example provide only geocoding or maps). A valid plugin must be set before the RouteModel can perform any useful operations. See also Plugin. This property holds the data of the route request. The primary data are the waypoint coordinates and possible further preferences (means of traveling, things to avoid on route etc). This read-only property holds the current status of the model.
Method DocumentationCancels any outstanding requests and clears errors. Model status will be set to either RouteModel.Null or RouteModel.Ready. Returns the Route at given index. Use count property to check the amount of routes available. The routes are indexed from zero, so the accessible range is 0...(count - 1). If you access out of bounds, a zero (null object) is returned and a warning is issued. Resets the model. All route data is cleared, any outstanding requests are aborted and possible errors are cleared. Model status will be set to RouteModel.Null Instructs the RouteModel to update its data. This is most useful when autoUpdate is disabled, to force a refresh when the query has been changed. |