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  · 

QSizeF Class Reference
[QtCore module]

The QSizeF class defines the size of a two-dimensional object using floating point precision. More...

 #include <QSizeF>

Public Functions

Related Non-Members

  • bool operator!= ( const QSizeF & s1, const QSizeF & s2 )
  • const QSizeF operator* ( const QSizeF & size, qreal factor )
  • const QSizeF operator* ( qreal factor, const QSizeF & size )
  • const QSizeF operator+ ( const QSizeF & s1, const QSizeF & s2 )
  • const QSizeF operator- ( const QSizeF & s1, const QSizeF & s2 )
  • const QSizeF operator/ ( const QSizeF & size, qreal divisor )
  • QDataStream & operator<< ( QDataStream & stream, const QSizeF & size )
  • bool operator== ( const QSizeF & s1, const QSizeF & s2 )
  • QDataStream & operator>> ( QDataStream & stream, QSizeF & size )

Detailed Description

The QSizeF class defines the size of a two-dimensional object using floating point precision.

A size is specified by a width() and a height(). It can be set in the constructor and changed using the setWidth(), setHeight(), or scale() functions, or using arithmetic operators. A size can also be manipulated directly by retrieving references to the width and height using the rwidth() and rheight() functions. Finally, the width and height can be swapped using the transpose() function.

The isValid() function determines if a size is valid. A valid size has both width and height greater than or equal to zero. The isEmpty() function returns true if either of the width and height is less than (or equal to) zero, while the isNull() function returns true only if both the width and the height is zero.

Use the expandedTo() function to retrieve a size which holds the maximum height and width of this size and a given size. Similarly, the boundedTo() function returns a size which holds the minimum height and width of this size and a given size.

The QSizeF class also provides the toSize() function returning a QSize copy of this size, constructed by rounding the width and height to the nearest integers.

QSizeF objects can be streamed as well as compared.

See also QSize, QPointF, and QRectF.


Member Function Documentation

QSizeF::QSizeF ()

Constructs an invalid size.

See also isValid().

QSizeF::QSizeF ( const QSize & size )

Constructs a size with floating point accuracy from the given size.

See also toSize().

QSizeF::QSizeF ( qreal width, qreal height )

Constructs a size with the given width and height.

QSizeF QSizeF::boundedTo ( const QSizeF & otherSize ) const

Returns a size holding the minimum width and height of this size and the given otherSize.

See also expandedTo() and scale().

QSizeF QSizeF::expandedTo ( const QSizeF & otherSize ) const

Returns a size holding the maximum width and height of this size and the given otherSize.

See also boundedTo() and scale().

qreal QSizeF::height () const

Returns the height.

See also width() and setHeight().

bool QSizeF::isEmpty () const

Returns true if either of the width and height is less than or equal to 0; otherwise returns false.

See also isNull() and isValid().

bool QSizeF::isNull () const

Returns true if both the width and height is 0; otherwise returns false.

See also isValid() and isEmpty().

bool QSizeF::isValid () const

Returns true if both the width and height is equal to or greater than 0; otherwise returns false.

See also isNull() and isEmpty().

qreal & QSizeF::rheight ()

Returns a reference to the height.

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

 QSizeF size(100, 10.2);
 size.rheight() += 5.5;

 // size becomes (100,15.7)

See also rwidth() and setHeight().

qreal & QSizeF::rwidth ()

Returns a reference to the width.

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

 QSizeF size(100.3, 10);
 size.rwidth() += 20.5;

  // size becomes (120.8,10)

See also rheight() and setWidth().

void QSizeF::scale ( qreal width, qreal height, Qt::AspectRatioMode mode )

Scales the size to a rectangle with the given width and height, according to the specified mode.

  • If mode is Qt::IgnoreAspectRatio, the size is set to (width, height).
  • If mode is Qt::KeepAspectRatio, the current size is scaled to a rectangle as large as possible inside (width, height), preserving the aspect ratio.
  • If mode is Qt::KeepAspectRatioByExpanding, the current size is scaled to a rectangle as small as possible outside (width, height), preserving the aspect ratio.

Example:

 QSizeF t1(10, 12);
 t1.scale(60, 60, Qt::IgnoreAspectRatio);
 // t1 is (60, 60)

 QSizeF t2(10, 12);
 t2.scale(60, 60, Qt::KeepAspectRatio);
 // t2 is (50, 60)

 QSizeF t3(10, 12);
 t3.scale(60, 60, Qt::KeepAspectRatioByExpanding);
 // t3 is (60, 72)

See also setWidth() and setHeight().

void QSizeF::scale ( const QSizeF & size, Qt::AspectRatioMode mode )

This is an overloaded member function, provided for convenience.

Scales the size to a rectangle with the given size, according to the specified mode.

void QSizeF::setHeight ( qreal height )

Sets the height to the given height.

See also height(), rheight(), and setWidth().

void QSizeF::setWidth ( qreal width )

Sets the width to the given width.

See also width(), rwidth(), and setHeight().

QSize QSizeF::toSize () const

Returns an integer based copy of this size.

Note that the coordinates in the returned size will be rounded to the nearest integer.

See also QSizeF().

void QSizeF::transpose ()

Swaps the width and height values.

See also setWidth() and setHeight().

qreal QSizeF::width () const

Returns the width.

See also height() and setWidth().

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

Multiplies both the width and height by the given factor and returns a reference to the size.

See also scale().

QSizeF & QSizeF::operator+= ( const QSizeF & size )

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

 QSizeF s( 3, 7);
 QSizeF r(-1, 4);
 s += r;

 // s becomes (2,11)

QSizeF & QSizeF::operator-= ( const QSizeF & size )

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

 QSizeF s( 3, 7);
 QSizeF r(-1, 4);
 s -= r;

 // s becomes (4,3)

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

Divides both the width and height by the given divisor and returns a reference to the size.

See also scale().


Related Non-Members

bool operator!= ( const QSizeF & s1, const QSizeF & s2 )

This is an overloaded member function, provided for convenience.

Returns true if s1 and s2 are different; otherwise returns false.

const QSizeF operator* ( const QSizeF & size, qreal factor )

This is an overloaded member function, provided for convenience.

Multiplies the given size by the given factor and returns the result.

See also QSizeF::scale().

const QSizeF operator* ( qreal factor, const QSizeF & size )

This is an overloaded member function, provided for convenience.

Multiplies the given size by the given factor and returns the result.

const QSizeF operator+ ( const QSizeF & s1, const QSizeF & s2 )

This is an overloaded member function, provided for convenience.

Returns the sum of s1 and s2; each component is added separately.

const QSizeF operator- ( const QSizeF & s1, const QSizeF & s2 )

This is an overloaded member function, provided for convenience.

Returns s2 subtracted from s1; each component is subtracted separately.

const QSizeF operator/ ( const QSizeF & size, qreal divisor )

This is an overloaded member function, provided for convenience.

Divides the given size by the given divisor and returns the result.

See also QSizeF::scale().

QDataStream & operator<< ( QDataStream & stream, const QSizeF & size )

This is an overloaded member function, provided for convenience.

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

See also Format of the QDataStream Operators.

bool operator== ( const QSizeF & s1, const QSizeF & s2 )

This is an overloaded member function, provided for convenience.

Returns true if s1 and s2 are equal; otherwise returns false.

QDataStream & operator>> ( QDataStream & stream, QSizeF & size )

This is an overloaded member function, provided for convenience.

Reads a size from the given stream into the given size 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 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 Qt Developer Network au hasard

Logo

Comment fermer une application

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 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