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  · 

Porting Applications from QtMobility Sensors to Qt Sensors

Overview

The initial release of Qt Sensors (5.0) is generally expected to be source compatible with QtMobility Sensors 1.2. This document attempts to explain where things must be changed in order to port applications to Qt Sensors.

QML

Compatibility for QML applications is provided by shipping the legacy QtMobility.sensors QML import. QML applications should not require any changes to continue operating.

Applications using the legacy QML import may not be able to trivially port over to the new QML import because the new QML import does not provide elements for every sensor like the legacy QML import does.

QML APIInformation about the Qt Sensors QML API
Legacy QML APIInformation about the legacy QtMobility.sensors QML API

C++

Includes

QtMobility Sensors installed headers into a Qt Sensors directory. This is also the directory that Qt Sensors uses. It is therefore expected that includes that worked with QtMobility Sensors should continue to work.

For example:

 #include <QAccelerometer>
 #include <qaccelerometer.h>
 #include <QtSensors/QAccelerometer>
 #include <QtSensors/qaccelerometer.h>

Macros and Namespace

QtMobility Sensors was built in a QtMobility namespace. This was enabled by the use of various macros. Qt Sensors does not normally build into a namespace and the macros from QtMobility no longer exist.

  • QTM_BEGIN_NAMESPACE
  • QTM_END_NAMESPACE
  • QTM_USE_NAMESPACE
  • QTM_PREPEND_NAMESPACE(x)

Note that Qt can be configured to build into a namespace. If Qt is built in this way then Qt Sensors is also built into the nominated namespace. However, as this is optional, the macros for this are typically defined to do nothing.

  • QT_BEGIN_NAMESPACE
  • QT_END_NAMESPACE
  • QT_USE_NAMESPACE
  • QT_PREPEND_NAMESPACE(x)

qtimestamp

qtimestamp was previously defined as an opaque type equivalent to a quint64. It existed as a class due to an implementation detail.

In Qt Sensors, the API uses quint64 instead of qtimestamp. qtimestamp still exists as a typedef so that applications that refer to qtimestamp can be compiled.

Project Files

QtMobility Sensors applications used this in their project files to enable the Sensors API.

 CONFIG += mobility
 MOBILITY += sensors

Applications should remove these lines and instead use this to enable the Qt Sensors API.

 QT += sensors
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