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  ·  Toutes les fonctions  ·  Vues d'ensemble  · 

QWhereabouts Class Reference
[QtLocationModule]

The QWhereabouts class is a base class for providing regular updates about one's global position, and other related information, at a particular point in time. More...

    #include <QWhereabouts>

Inherits QObject.

Inherited by QNmeaWhereabouts.

Public Types

  • enum State { NotAvailable, Initializing, Available, PositionFixAcquired }
  • enum UpdateMethod { AssistedUpdate, NetworkBasedUpdate, TerminalBasedUpdate }

Properties

  • 1 property inherited from QObject

Public Functions

  • 29 public functions inherited from QObject

Public Slots

  • 1 public slot inherited from QObject

Signals

  • void stateChanged ( QWhereabouts::State state )
  • void updated ( const QWhereaboutsUpdate & update )

Protected Functions

  • 7 protected functions inherited from QObject

Additional Inherited Members

  • 1 public type inherited from QObject
  • 4 static public members inherited from QObject
  • 2 protected variables inherited from QObject

Detailed Description

The QWhereabouts class is a base class for providing regular updates about one's global position, and other related information, at a particular point in time.

Call QWhereaboutsFactory::create() to get a QWhereabouts object, then call startUpdates() or requestUpdate() to receive positional data through the updated() signal.

An example:

    class SimpleLocationDemo : public QObject
    {
        Q_OBJECT
    public:
        SimpleLocationDemo(QObject *parent = 0)
            : QObject(parent)
        {
            QWhereabouts *whereabouts = QWhereaboutsFactory::create();
            connect(whereabouts, SIGNAL(updated(QWhereaboutsUpdate)),
                    SLOT(updated(QWhereaboutsUpdate)));

            whereabouts->startUpdates();
        }

    private slots:
        void updated(const QWhereaboutsUpdate &update)
        {
            // respond to update here
        }
    };

Subclassing QWhereabouts

When startUpdates() or requestUpdate() is first called, a QWhereabouts subclass instance should change state to QWhereabouts::Initializing. If initialization succeeds, the state should change to QWhereabouts::Available, and then to QWhereabouts::PositionFixAcquired once a position fix is acquired and updates are possible. Otherwise, if initialization fails, the state should return to QWhereabouts::NotAvailable.

Note that updated() should only be emitted while the state is QWhereabouts::PositionFixAcquired, and the provided update should always have valid date & time and coordinate values. Receivers of the signal should be able to assume that the provided update is valid without additional verification.

Subclasses can call emitUpdated() to set the value of lastUpdate() and emit updated().

See also QWhereaboutsFactory, QWhereaboutsPlugin, and Location Services.


Member Type Documentation

enum QWhereabouts::State

This enum defines the possible states for a whereabouts object.

ConstantValueDescription
QWhereabouts::NotAvailable0Positional data cannot be retrieved. This is the default state.
QWhereabouts::Initializing1The object is in the initialization stage. It will change to the Available state when it is successfully initialized.
QWhereabouts::Available2The object is able to receive position data, but it is not currently able to provide position updates as there is no position fix.
QWhereabouts::PositionFixAcquired3A position fix has been acquired and position updates can now be provided.

enum QWhereabouts::UpdateMethod
flags QWhereabouts::UpdateMethods

This enum defines the methods that may be used to calculate and retrieve the information to provide a QWhereaboutsUpdate.

ConstantValueDescription
QWhereabouts::AssistedUpdate0x01Position data is calculated using assistance data from an AGPS module. (This is generally used to obtain faster and more accurate fixes.)
QWhereabouts::NetworkBasedUpdate0x02The position data is calculated by a remote server.
QWhereabouts::TerminalBasedUpdate0x04The position data is calculated by the terminal (i.e. the mobile device).

The UpdateMethods type is a typedef for QFlags<UpdateMethod>. It stores an OR combination of UpdateMethod values.


Property Documentation

updateInterval : int

This property holds this property holds the interval between each update, in milliseconds.

If setUpdateInterval() is called after startUpdates(), the interval change will not take effect until startUpdates() is called again.

The default update interval is 0. An update interval of 0 means that updated() is emitted as soon as a valid update becomes available.

Access functions:

  • int updateInterval () const
  • void setUpdateInterval ( int interval )

Member Function Documentation

QWhereabouts::QWhereabouts ( UpdateMethods updateMethods = 0, QObject * parent = 0 )

Constructs a whereabouts object with the given updateMethods and parent.

QWhereabouts::~QWhereabouts ()   [virtual]

Destroys the whereabouts object.

void QWhereabouts::emitUpdated ( const QWhereaboutsUpdate & update )   [protected]

Sets the value of lastUpdate() to update and emits updated().

Note that updated() should only be emitted while the state is QWhereabouts::PositionFixAcquired, and the provided update should always have valid date/time and coordinate values. Receivers of the signal should be able to assume that the provided update is valid without additional verification.

QWhereaboutsUpdate QWhereabouts::lastUpdate () const

Returns the last update that was emitted through updated(), or an invalid update if no updates have been emitted yet.

The returned update may contain out-of-date information if updated() has not been emitted for some time. Use requestUpdate() if you require fresh positional data.

See also startUpdates() and emitUpdated().

void QWhereabouts::requestUpdate ()   [pure virtual slot]

Requests that updated() be emitted with the current whereabouts if possible. This can be called regardless of whether startUpdates() has already been called.

This is useful if you need to retrieve the current whereabouts but you do not need the periodic updates offered by startUpdates().

If the state is currently QWhereabouts::NotAvailable, the object will first be initialized and will begin to provide updates once it is in the QWhereabouts::PositionFixAcquired state.

See also startUpdates() and lastUpdate().

void QWhereabouts::setState ( State state )   [protected]

Sets the current state to state and emits stateChanged() if necessary.

See also state().

void QWhereabouts::startUpdates ()   [pure virtual slot]

Starts emitting updated() with the interval specified by updateInterval(), or less frequently if updates are not available at a particular time. If updateInterval() is 0, updated() is emitted as soon as a valid update becomes available.

If startUpdates() has already been called, this restarts with updateInterval() as the new update interval.

If the state is currently QWhereabouts::NotAvailable, the object will first be initialized and will begin to provide updates once it is in the QWhereabouts::PositionFixAcquired state.

See also stopUpdates().

void QWhereabouts::startUpdates ( int msec )   [slot]

This is an overloaded member function, provided for convenience.

Starts providing updates with an update interval of msec milliseconds.

State QWhereabouts::state () const

Returns the current state.

See also setState().

void QWhereabouts::stateChanged ( QWhereabouts::State state )   [signal]

This signal is emitted when the whereabouts object's state changes to state.

See also setState().

void QWhereabouts::stopUpdates ()   [pure virtual slot]

Stops emitting updated() at regular intervals.

See also startUpdates().

UpdateMethods QWhereabouts::updateMethods () const

Returns the methods that this whereabouts object uses to retrieve positional data.

void QWhereabouts::updated ( const QWhereaboutsUpdate & update )   [signal]

This signal is emitted to notify recipients of a newly available update.

See also startUpdates(), stopUpdates(), and requestUpdate().

Publicité

Best Of

Actualités les plus lues

Semaine
Mois
Année
  1. « Quelque chose ne va vraiment pas avec les développeurs "modernes" », un développeur à "l'ancienne" critique la multiplication des bibliothèques 64
  2. Apercevoir la troisième dimension ou l'utilisation multithreadée d'OpenGL dans Qt, un article des Qt Quarterly traduit par Guillaume Belz 0
  3. Les développeurs ignorent-ils trop les failles découvertes dans leur code ? Prenez-vous en compte les remarques des autres ? 17
  4. BlackBerry 10 : premières images du prochain OS de RIM qui devrait intégrer des widgets et des tuiles inspirées de Windows Phone 0
  5. Quelles nouveautés de C++11 Visual C++ doit-il rapidement intégrer ? Donnez-nous votre avis 10
  6. Adieu qmake, bienvenue qbs : Qt Building Suite, un outil déclaratif et extensible pour la compilation de projets Qt 17
  7. La rubrique Qt a besoin de vous ! 1
Page suivante

Le blog Digia au hasard

Logo

Créer des applications avec un style Metro avec Qt, exemples en QML et C++, un article de Digia Qt traduit par Thibaut Cuvelier

Le blog Digia est l'endroit privilégié pour la communication sur l'édition commerciale de Qt, où des réponses publiques sont apportées aux questions les plus posées au support. Lire l'article.

Communauté

Ressources

Liens utiles

Contact

  • Vous souhaitez rejoindre la rédaction ou proposer un tutoriel, une traduction, une question... ? Postez dans le forum Contribuez ou contactez-nous par MP ou par email (voir en bas de page).

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 qtextended4.4
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