QGeoRoutingManager Class ReferenceThe QGeoRoutingManager class provides support for geographic routing operations. More... #include <QGeoRoutingManager> Inherits: QObject. This class was introduced in Qt Mobility 1.1. Public Functions
Signals
Additional Inherited Members
Detailed DescriptionThe QGeoRoutingManager class provides support for geographic routing operations. The calculateRoute() and updateRoute() methods function QGeoRouteReply objects, which manage these operations and report on the result of the operations and any errors which may have occurred. The calculateRoute() function is used to find a route (or routes) that follows a set of waypoints and matches various other criteria. The QGeoRouteRequest class is used to specify this information. If supportsRouteUpdates() returns true then the QGeoRoutingManager supports updating route information based on position updates. This will cause the travel time and distance estimates to be updated, and any QGeoRouteSegments already traversed to be removed from the route. The updates can be triggered with the updateRoute() function, which makes use of the QGeoPositionInfo instances emitted as position updates by QGeoPositionInfoSource. Instances of QGeoRoutingManager can be accessed with QGeoServiceProvider::routingManager(). A small example of the usage of QGeoRoutingManager and QGeoRouteRequests follows: class MyRouteHandler : public QObject { Q_OBJECT public: MyRouteHandler(QGeoRoutingManager *routingManager, const QGeoCoordinate &origin, const QGeoCoordinate &destination) { QGeoRouteRequest request(origin, destination); // The request defaults to the fastest route by car, which is // equivalent to: // request.setTravelMode(QGeoRouteRequest::CarTravel); // request.setRouteOptimization(QGeoRouteRequest::FastestRoute); request.setAvoidFeatureTypes(QGeoRouteRequest::AvoidTolls); request.setAvoidFeatureTypes(QGeoRouteRequest::AvoidMotorPoolLanes); QGeoRouteRequest::AvoidFeaturesTypes avoidableFeatures = routingManager->supportedAvoidFeatureTypes(); if (!(avoidableFeatures & request.avoidFeatureTypes())) { // ... inform the user that the routing manager does not // provide support for avoiding tolls and/or motor pool lanes ... return; } QGeoRouteReply *reply = routingManager->calculateRoute(request); if (reply->isFinished()) { if (reply->error() == QGeoRouteReply::NoError) { routeCalculated(reply); } else { routeError(reply, reply->error(), reply->errorString()); } return; } connect(routingManager, SIGNAL(finished(QGeoRouteReply*)), this, SLOT(routeCalculated(QGeoRouteReply*))); connect(routingManager, SIGNAL(error(QGeoRouteReply*,QGeoRouteReply::Error,QString)), this, SLOT(routeError(QGeoRouteReply*,QGeoRouteReply::Error,QString))); } private slots: void routeCalculated(QGeoRouteReply *reply) { // A route request can ask for several alternative routes ... if (reply->routes().size() != 0) { // ... but by default it will only get a single route QGeoRoute route = reply->routes().at(0); //... now we have to make use of the route ... } reply->deleteLater(); } void routeError(QGeoRouteReply *reply, QGeoRouteReply:Error error, const QString &errorString) { // ... inform the user that an error has occurred ... reply->deleteLater(); } }; Member Function Documentation
|
Publicité
Best OfActualités les plus luesSemaine
Mois
Année
![]()
![]() Le Qt Quarterly au hasard![]() Le tri des QListViewQt Quarterly est la revue trimestrielle proposée par Nokia et à destination des développeurs Qt. Ces articles d'une grande qualité technique sont rédigés par des experts Qt. Lire l'article.
CommunautéRessources
Liens utilesContact
Qt dans le magazine |
Cette page est une traduction d'une page de la documentation de Qt, écrite par Nokia Corporation and/or its subsidiary(-ies). Les éventuels problèmes résultant d'une mauvaise traduction ne sont pas imputables à Nokia. | Qt qtmobility-1.2 | |
Copyright © 2012 Developpez LLC. Tous droits réservés Developpez LLC. Aucune reproduction, même partielle, ne peut être faite de ce site et de l'ensemble de son contenu : textes, documents et images sans l'autorisation expresse de Developpez LLC. Sinon, vous encourez selon la loi jusqu'à 3 ans de prison et jusqu'à 300 000 E de dommages et intérêts. Cette page est déposée à la SACD. | ||
Vous avez déniché une erreur ? Un bug ? Une redirection cassée ? Ou tout autre problème, quel qu'il soit ? Ou bien vous désirez participer à ce projet de traduction ? N'hésitez pas à nous contacter ou par MP ! |
Copyright © 2000-2012 - www.developpez.com