Viadeo Twitter Google Bookmarks ! Facebook Digg del.icio.us MySpace Yahoo MyWeb Blinklist Netvouz Reddit Simpy StumbleUpon Bookmarks Windows Live Favorites 
Logo Documentation Qt ·  Page d'accueil  ·  Toutes les classes  ·  Classes principales  ·  Annotées  ·  Classes groupées  ·  Modules  ·  Fonctions  · 

PositionSource

The PositionSource element provides the device's current position. More...

Inherits QtObject

This type was introduced in Qt Location 5.0.

Properties

Signals

Methods

Detailed Description

The PositionSource element provides information about the user device's current position. The position is available as a Position element, which contains all the standard parameters typically available from GPS and other similar systems, including longitude, latitude, speed and accuracy details.

As different position sources are available on different platforms and devices, these are categorized by their basic type (Satellite, NonSatellite, and AllPositioningMethods). The available methods for the current platform can be enumerated in the supportedPositioningMethods property.

To indicate which methods are suitable for your application, set the preferredPositioningMethods property. If the preferred methods are not available, the default source of location data for the platform will be chosen instead. If no default source is available (because none are installed for the runtime platform, or because it is disabled), the valid property will be set to false.

The updateInterval property can then be used to indicate how often your application wishes to receive position updates. The start(), stop() and update() methods can be used to control the operation of the PositionSource, as well as the active property, which when set is equivalent to calling start() or stop().

When the PositionSource is active, position updates can be retrieved either by simply using the position property in a binding (as the value of another item's property), or by providing an implementation of the onPositionChanged signal-handler.

Example Usage

The following example shows a simple PositionSource used to receive updates every second and print the longitude and latitude out to the console.

 PositionSource {
     id: src
     updateInterval: 1000
     active: true

     onPositionChanged: {
         var coord = src.position.coordinate;
         console.log("Coordinate:", coord.longitude, coord.latitude);
     }
 }

The Flickr example application shows how to use a PositionSource in your application to retrieve local data for users from a REST web service.

See also QtLocation5::Position and QGeoPositionInfoSource.

Property Documentation

active : bool

This property indicates whether the position source is active. Setting this property to false equals calling stop, and setting this property true equals calling start.

See also start, stop, and update.


nmeaSource : url

This property holds the source for NMEA (National Marine Electronics Association) position-specification data (file). One purpose of this property is to be of development convenience.

Setting this property will override any other position source. Currently only files local to the .qml -file are supported. The NMEA source is created in simulation mode, meaning that the data and time information in the NMEA source data is used to provide positional updates at the rate at which the data was originally recorded.

If nmeaSource has been set for a PositionSource element, there is no way to revert back to non-file sources.


plugin : string

This property holds the unique internal name for the plugin currently providing position information.

Setting the property causes the PositionSource to use a particular backend plugin. If the PositionSource is active at the time that the plugin property is changed, it will become inactive.


read-onlyposition : Position

This property holds the last known positional data. It is a read-only property.

The Position element has different positional member variables, whose validity can be checked with appropriate validity functions (for example sometimes an update does not have speed or altitude data).

However, whenever a positionChanged signal has been received, at least position::coordinate::latitude, position::coordinate::longitude, and position::timestamp can be assumed to be valid.

See also start, stop, and update.


preferredPositioningMethods : enumeration

This property holds the preferred positioning methods of the current source.

  • PositionSource.SatellitePositioningMethod - Satellite-based positioning methods such as GPS should be preferred.
  • PositionSource.NonSatellitePositioningMethod - Non-satellite-based methods should be preferred.
  • PositionSource.AllPositioningMethods - Any positioning methods are acceptable.

read-onlysourceError : enumeration

This property holds the error which last occured with the PositionSource.

  • PositionSource.AccessError - The connection setup to the remote positioning backend failed because the application lacked the required privileges.
  • PositionSource.ClosedError - The remote positioning backend closed the connection, which happens for example in case the user is switching location services to off. This object becomes invalid and should be deleted. A new source can be declared later on to check whether the positioning backend is up again.
  • PositionSource.UnknownSourceError - An unidentified error occurred.

read-onlysupportedPositioningMethods : enumeration

This property holds the supported positioning methods of the current source.

  • PositionSource.NoPositioningMethod - No positioning methods supported (no source).
  • PositionSource.SatellitePositioningMethod - Satellite-based positioning methods such as GPS are supported.
  • PositionSource.NonSatellitePositioningMethod - Non-satellite-based methods are supported.
  • PositionSource.AllPositioningMethods - Both satellite-based and non-satellite positioning methods are supported.

updateInterval : bool

This property holds the desired interval between updates (milliseconds).

See also QGeoPositionInfoSource::updateInterval().


read-onlyvalid : bool

This property is true if the PositionSource element has acquired a valid backend plugin to provide data. If false, other methods on the PositionSource will have no effect.

Applications should check this property to determine whether positioning is available and enabled on the runtime platform, and react accordingly.


Signal Documentation

PositionSource::positionChanged()

This signal is sent when a position update has been received from the location source. Upon receiving this signal, at least position::latitude, position::longitude, and position::timestamp members of the position have been updated.

See also updateInterval and onPositionChanged.


Method Documentation

PositionSource::start()

Requests updates from the location source. Uses updateInterval if set, default interval otherwise. If there is no source available, this method has no effect.

See also stop, update, and active.


PositionSource::stop()

Stops updates from the location source. If there is no source available or it is not active, this method has no effect.

See also start, update, and active.


PositionSource::update()

A convenience method to request single update from the location source. If there is no source available, this method has no effect.

If the position source is not active, it will be activated for as long as it takes to receive an update, or until the request times out. The request timeout period is source-specific.

See also start, stop, and active.


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 5.0-snapshot
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 !
 
 
 
 
Partenaires

Hébergement Web