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  · 

QGeoMapCustomObject Class Reference

The QGeoMapCustomObject class is a QGeoMapObject used to draw a QGraphicsItem on a map. More...

 #include <QGeoMapCustomObject>

Inherits: QGeoMapObject.

This class was introduced in Qt Mobility 1.2.

Properties

Public Functions

QGeoMapCustomObject ()
QGeoMapCustomObject ( const QGeoCoordinate & coordinate, const QPoint & offset = QPoint( 0, 0 ) )
~QGeoMapCustomObject ()
QGraphicsItem * graphicsItem () const
QPoint offset () const
void setGraphicsItem ( QGraphicsItem * graphicsItem )
void setOffset ( const QPoint & offset )
void setOrigin ( const QGeoCoordinate & origin )
void setTransformType ( const TransformType & type )
void setUnits ( const CoordinateUnit & unit )
void update ()

Reimplemented Public Functions

virtual QGeoMapObject::Type type () const

Signals

void graphicsItemChanged ( QGraphicsItem * graphicsItem )
void offsetChanged ( const QPoint & offset )
void triggerUpdate ()

Additional Inherited Members

  • 1 public slot inherited from QObject
  • 1 public variable inherited from QObject
  • 4 static public members inherited from QObject
  • 3 protected functions inherited from QGeoMapObject
  • 7 protected functions inherited from QObject
  • 2 protected variables inherited from QObject

Detailed Description

The QGeoMapCustomObject class is a QGeoMapObject used to draw a QGraphicsItem on a map.

Any arbitrary QGraphicsItem can be associated with a QGeoMapCustomObject, and to this end it contains support for interpreting the coordinates of the QGraphicsItem in a variety of different ways.

For example, the following code creates a QGraphicsEllipseItem and a QGeoMapCustomObject to display it. The EllipseItem extends from the origin point, out 20 meters to the east and 30 metres south.

 QGraphicsEllipseItem *ellipseItem = new QGraphicsEllipseItem;
 ellipseItem->setRect(0, 0, 20, 30);

 QGeoMapCustomObject *mapObject = new QGeoMapCustomObject;
 mapObject->setGraphicsItem(ellipseItem);
 mapObject->setUnits(QGeoMapObject::MeterUnit);
 mapObject->setOrigin(QGeoCoordinate(-27.5796, 153.1));

Units and coordinates

The local units and coordinates of the QGraphicsItem are transformed onto the map based on the units, origin, transformType and transform properties. Several systems are available, including pixels, meters and seconds of arc.

It should be noted that both pixel and meter coordinate systems are south- oriented (ie, positive Y axis faces south on the map). However, the RelativeArcSeconds unit system faces north to align with the standard latitude grid. The Y axis can be flipped if necessary by making use of the GraphicsItem's transform property

 QTransform northFlip;
 northFlip.scale(0, -1);

 ellipseItem->setTransform(northFlip);

Transform methods

Normally, the GraphicsItem will be transformed into map coordinates using a bilinear interpolation. Another option is the ExactTransform, which converts the GraphicsItem exactly into map coordinates, but is only available for certain subclasses of QGraphicsItem. Other interpolation methods may be provided in future for greater accuracy near poles and in different map projections, without the limitations of ExactTransform.

Calling setUnits() or setting the units property will result in the default value of transformType being restored. See QGeoMapObject::transformType for more details.

Caveats

Other than the coordinate system features, there are a few differences with using QGraphicsItems on a map compared to using them on a standard QGraphicsScene. One of the most important of these is the use of the update() function. When an application changes anything that has an effect upon the appearance, size, shape etc of the QGraphicsItem, it must call QGeoMapCustomObject::update() to ensure that the map is updated.

Another is the use of child items of a QGraphicsItem. These are supported in more or less the same manner as in QGraphicsScene, with the exception of use in concert with ExactTransform -- any object with transformType set to ExactTransform will not have children of its QGraphicsItem drawn on the map.

Property Documentation

graphicsItem : QGraphicsItem *

This property holds the graphics item which will be drawn by this custom object.

If the graphics item is 0 then nothing will be drawn.

This property was introduced in Qt Mobility 1.2.

Access functions:

QGraphicsItem * graphicsItem () const
void setGraphicsItem ( QGraphicsItem * graphicsItem )

Notifier signal:

void graphicsItemChanged ( QGraphicsItem * graphicsItem )

offset : QPoint

This property holds the offset in pixels at which the graphics item will be drawn by this custom object.

The default value of this property is QPoint(0, 0). If this value is not changed the upper left coordinate of the graphics item will be drawn at the coordinate specified by QGeoMapCustomObject::coordinate.

The offset is in pixels and is independent of the zoom level of the map.

This property was introduced in Qt Mobility 1.2.

Access functions:

QPoint offset () const
void setOffset ( const QPoint & offset )

Notifier signal:

void offsetChanged ( const QPoint & offset )

Member Function Documentation

QGeoMapCustomObject::QGeoMapCustomObject ()

Constructs a new custom object.

QGeoMapCustomObject::QGeoMapCustomObject ( const QGeoCoordinate & coordinate, const QPoint & offset = QPoint( 0, 0 ) )

Constructs a new custom object which will draw a QGraphicsItem at an offset of offset pixels from the coordinate coordinate.

This function was introduced in Qt Mobility 1.2.

QGeoMapCustomObject::~QGeoMapCustomObject ()

Destroys this custom object.

void QGeoMapCustomObject::graphicsItemChanged ( QGraphicsItem * graphicsItem ) [signal]

This signal is emitted when the graphics item which this custom object draws is changed.

The new value will be graphicsItem.

This function was introduced in Qt Mobility 1.2.

void QGeoMapCustomObject::offsetChanged ( const QPoint & offset ) [signal]

This signal is emitted when the on-screen offset from the coordinate at which this custom object should be drawn has changed.

The new value will be offset.

This function was introduced in Qt Mobility 1.2.

void QGeoMapCustomObject::setOrigin ( const QGeoCoordinate & origin )

Sets the origin of the object to origin.

This function was introduced in Qt Mobility 1.2.

void QGeoMapCustomObject::setTransformType ( const TransformType & type )

Sets the transform type of the object to type.

This function was introduced in Qt Mobility 1.2.

void QGeoMapCustomObject::setUnits ( const CoordinateUnit & unit )

Sets the coordinate units of the object to unit.

Note that setting this property will reset the transformType property to the default for the units given. For PixelUnit, this is ExactTransform, and for all others, BilinearTransform.

This function was introduced in Qt Mobility 1.2.

void QGeoMapCustomObject::triggerUpdate () [signal]

This signal indicates that the graphics item has changed and that the map needs to be updated.

This function was introduced in Qt Mobility 1.2.

QGeoMapObject::Type QGeoMapCustomObject::type () const [virtual]

Reimplemented from QGeoMapObject::type().

This function was introduced in Qt Mobility 1.2.

void QGeoMapCustomObject::update ()

If the graphics item is modified this method should be called immediately afterwards to inform the map that an update is required. .

This method causes the triggerUpdate() signal to be emitted.

This function was introduced in Qt Mobility 1.2.

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 80
  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. 2017 : un quinquennat pour une nouvelle version du C++ ? Possible, selon Herb Sutter 6
Page suivante

Le Qt Developer Network au hasard

Logo

QML et les styles

Le Qt Developer Network est un réseau de développeurs Qt anglophone, où ils peuvent partager leur expérience sur le framework. 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 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 !
 
 
 
 
Partenaires

Hébergement Web