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  · 

QPointF Class Reference
[QtCore module]

The QPointF class defines a point in the plane using floating point precision. More...

 #include <QPointF>

Public Functions

Related Non-Members

  • bool operator!= ( const QPointF & p1, const QPointF & p2 )
  • const QPointF operator* ( const QPointF & point, qreal factor )
  • const QPointF operator* ( qreal factor, const QPointF & point )
  • const QPointF operator+ ( const QPointF & p1, const QPointF & p2 )
  • const QPointF operator- ( const QPointF & p1, const QPointF & p2 )
  • const QPointF operator- ( const QPointF & point )
  • const QPointF operator/ ( const QPointF & point, qreal divisor )
  • QDataStream & operator<< ( QDataStream & stream, const QPointF & point )
  • bool operator== ( const QPointF & p1, const QPointF & p2 )
  • QDataStream & operator>> ( QDataStream & stream, QPointF & point )

Detailed Description

The QPointF class defines a point in the plane using floating point precision.

A point is specified by a x coordinate and an y coordinate which can be accessed using the x() and y() functions. The coordinates of the point are specified using floating point numbers for accuracy. The isNull() function returns true if both x and y are set to 0.0. The coordinates can be set (or altered) using the setX() and setY() functions, or alternatively the rx() and ry() functions which return references to the coordinates (allowing direct manipulation).

Given a point p, the following statements are all equivalent:

 QPointF p;

 p.setX(p.x() + 1.0);
 p += QPoint(1.0, 0.0);
 p.rx()++;

A QPointF object can also be used as a vector: Addition and subtraction are defined as for vectors (each component is added separately). A QPointF object can also be divided or multiplied by an int or a qreal.

In addition, the QPointF class provides a constructor converting a QPoint object into a QPointF object, and a corresponding toPoint() function which returns a QPoint copy of this point. Finally, QPointF objects can be streamed as well as compared.

See also QPoint and QPolygonF.


Member Function Documentation

QPointF::QPointF ()

Constructs a null point, i.e. with coordinates (0.0, 0.0)

See also isNull().

QPointF::QPointF ( const QPoint & point )

Constructs a copy of the given point.

See also toPoint().

QPointF::QPointF ( qreal x, qreal y )

Constructs a point with the given coordinates (x, y).

See also setX() and setY().

bool QPointF::isNull () const

Returns true if both the x and y coordinates are set to 0.0, otherwise returns false.

qreal & QPointF::rx ()

Returns a reference to the x coordinate of this point.

Using a reference makes it possible to directly manipulate x. For example:

 QPoint p(1.1, 2.5);
 p.rx()--;   // p becomes (0.1, 2.5)

See also x() and setX().

qreal & QPointF::ry ()

Returns a reference to the y coordinate of this point.

Using a reference makes it possible to directly manipulate y. For example:

 QPoint p(1.1, 2.5);
 p.ry()++;   // p becomes (1.1, 3.5)

See also y() and setY().

void QPointF::setX ( qreal x )

Sets the x coordinate of this point to the given x coordinate.

See also x() and setY().

void QPointF::setY ( qreal y )

Sets the y coordinate of this point to the given y coordinate.

See also y() and setX().

QPoint QPointF::toPoint () const

Rounds the coordinates of this point to the nearest integer, and returns a QPoint object with the rounded coordinates.

See also QPointF().

qreal QPointF::x () const

Returns the x-coordinate of this point.

See also setX() and rx().

qreal QPointF::y () const

Returns the y-coordinate of this point.

See also setY() and ry().

QPointF & QPointF::operator*= ( qreal factor )

Multiplies this point's coordinates by the given factor, and returns a reference to this point. For example:

 QPoint p(-1.1, 4.1);
 p *= 2.5;    // p becomes (-2.75,10.25)

See also operator/=().

QPointF & QPointF::operator+= ( const QPointF & point )

Adds the given point to this point and returns a reference to this point. For example:

 QPoint p( 3.1, 7.1);
 QPoint q(-1.0, 4.1);
 p += q;    // p becomes (2.1, 11.2)

See also operator-=().

QPointF & QPointF::operator-= ( const QPointF & point )

Subtracts the given point from this point and returns a reference to this point. For example:

 QPoint p( 3.1, 7.1);
 QPoint q(-1.0, 4.1);
 p -= q;    // p becomes (4.1, 3.0)

See also operator+=().

QPointF & QPointF::operator/= ( qreal divisor )

Divides both x and y by the given divisor, and returns a reference to this point. For example:

 QPoint p(-2.75, 10.25);
 p /= 2.5;           // p becomes (-1.1,4.1)

See also operator*=().


Related Non-Members

bool operator!= ( const QPointF & p1, const QPointF & p2 )

This is an overloaded member function, provided for convenience.

Returns true if p1 is not equal to p2; otherwise returns false.

const QPointF operator* ( const QPointF & point, qreal factor )

This is an overloaded member function, provided for convenience.

Returns a copy of the given point, multiplied by the given factor.

See also QPointF::operator*=().

const QPointF operator* ( qreal factor, const QPointF & point )

This is an overloaded member function, provided for convenience.

Returns a copy of the given point, multiplied by the given factor.

const QPointF operator+ ( const QPointF & p1, const QPointF & p2 )

This is an overloaded member function, provided for convenience.

Returns a QPointF object that is the sum of the given points, p1 and p2; each component is added separately.

See also QPointF::operator+=().

const QPointF operator- ( const QPointF & p1, const QPointF & p2 )

This is an overloaded member function, provided for convenience.

Returns a QPointF object that is formed by subtracting p2 from p1; each component is subtracted separately.

See also QPointF::operator-=().

const QPointF operator- ( const QPointF & point )

This is an overloaded member function, provided for convenience.

Returns a QPointF object that is formed by changing the sign of both components of the given point.

Equivalent to QPointF(0,0) - point.

const QPointF operator/ ( const QPointF & point, qreal divisor )

This is an overloaded member function, provided for convenience.

Returns the QPointF object formed by dividing both components of the given point by the given divisor.

See also QPointF::operator/=().

QDataStream & operator<< ( QDataStream & stream, const QPointF & point )

This is an overloaded member function, provided for convenience.

Writes the given point to the given stream and returns a reference to the stream.

See also Format of the QDataStream Operators.

bool operator== ( const QPointF & p1, const QPointF & p2 )

This is an overloaded member function, provided for convenience.

Returns true if p1 is equal to p2; otherwise returns false.

QDataStream & operator>> ( QDataStream & stream, QPointF & point )

This is an overloaded member function, provided for convenience.

Reads a point from the given stream into the given point and returns a reference to the stream.

See also Format of the QDataStream Operators.

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 44
  2. Microsoft ouvre aux autres compilateurs C++ AMP, la spécification pour la conception d'applications parallèles C++ utilisant le GPU 22
  3. Les développeurs ignorent-ils trop les failles découvertes dans leur code ? Prenez-vous en compte les remarques des autres ? 17
  4. RIM : « 13 % des développeurs ont gagné plus de 100 000 $ sur l'AppWord », Qt et open-source au menu du BlackBerry DevCon Europe 0
  5. 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
  6. Quelles nouveautés de C++11 Visual C++ doit-il rapidement intégrer ? Donnez-nous votre avis 10
  7. Adieu qmake, bienvenue qbs : Qt Building Suite, un outil déclaratif et extensible pour la compilation de projets Qt 17
Page suivante

Le Qt Quarterly au hasard

Logo

XQuery et la météo

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