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  · 

QSize Class Reference
[QtCore module]

The QSize class defines the size of a two-dimensional object. More...

#include <QSize>

Public Functions

Related Non-Members

  • bool operator!= ( const QSize & s1, const QSize & s2 )
  • const QSize operator* ( const QSize & size, qreal coeff )
  • const QSize operator* ( qreal coeff, const QSize & size )
  • const QSize operator+ ( const QSize & s1, const QSize & s2 )
  • const QSize operator- ( const QSize & s1, const QSize & s2 )
  • const QSize operator/ ( const QSize & size, qreal divisor )
  • QDataStream & operator<< ( QDataStream & s, const QSize & sz )
  • bool operator== ( const QSize & s1, const QSize & s2 )
  • QDataStream & operator>> ( QDataStream & s, QSize & sz )

Detailed Description

The QSize class defines the size of a two-dimensional object.

A size is specified by a width and a height.

The size can be set in the constructor and changed with setWidth(), setHeight(), or scale(), or using arithmetic operators. You can swap the width and height with transpose(). You can get a size which holds the maximum height and width of two sizes using expandedTo(), and the minimum height and width of two sizes using boundedTo().

See also QPoint, QRect, and QSizeF.


Member Function Documentation

QSize::QSize ()

Constructs a size with an invalid width and height.

See also isValid(), setWidth(), and setHeight().

QSize::QSize ( int w, int h )

Constructs a size with width w and height h.

QSize QSize::boundedTo ( const QSize & otherSize ) const

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

See also expandedTo(), scale(), setWidth(), and setHeight().

QSize QSize::expandedTo ( const QSize & otherSize ) const

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

See also boundedTo(), scale(), setWidth(), and setHeight().

int QSize::height () const

Returns the height.

See also width() and setHeight().

bool QSize::isEmpty () const

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

See also isNull(), isValid(), width(), and height().

bool QSize::isNull () const

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

See also isValid(), isEmpty(), width(), and height().

bool QSize::isValid () const

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

See also isNull(), isEmpty(), width(), and height().

int & QSize::rheight ()

Returns a reference to the height.

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

Example:

    QSize s(100, 10);
    s.rheight() += 5;                // s becomes (100,15)

See also rwidth() and setHeight().

int & QSize::rwidth ()

Returns a reference to the width.

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

Example:

    QSize s(100, 10);
    s.rwidth() += 20;                // s becomes (120,10)

See also rheight() and setWidth().

void QSize::scale ( int w, int h, Qt::AspectRatioMode mode )

Scales the size to a rectangle of width w and height h according to the Qt::AspectRatioMode mode.

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

Example:

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

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

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

See also boundedTo(), expandedTo(), setWidth(), and setHeight().

void QSize::scale ( const QSize & s, Qt::AspectRatioMode mode )

This is an overloaded member function, provided for convenience. It behaves essentially like the above function.

Equivalent to scale(s.width(), s.height(), mode).

void QSize::setHeight ( int h )

Sets the height to h.

See also height(), rheight(), setWidth(), expandedTo(), boundedTo(), scale(), and transpose().

void QSize::setWidth ( int w )

Sets the width to w.

See also width(), rwidth(), setHeight(), expandedTo(), boundedTo(), scale(), and transpose().

void QSize::transpose ()

Swaps the width and height values.

See also expandedTo(), boundedTo(), setWidth(), and setHeight().

int QSize::width () const

Returns the width.

See also height() and setWidth().

QSize & QSize::operator*= ( qreal coeff )

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

Note that the result is rounded to the nearest integer.

QSize & QSize::operator+= ( const QSize & s )

Adds s to the size and returns a reference to this size.

Example:

    QSize s( 3, 7);
    QSize r(-1, 4);
    s += r;                        // s becomes (2,11)

QSize & QSize::operator-= ( const QSize & s )

Subtracts s from the size and returns a reference to this size.

Example:

    QSize s( 3, 7);
    QSize r(-1, 4);
    s -= r;                        // s becomes (4,3)

QSize & QSize::operator/= ( qreal coeff )

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

Note that the result is rounded to the nearest integer.

See also QSize::scale().


Related Non-Members

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

This is an overloaded member function, provided for convenience. It behaves essentially like the above function.

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

const QSize operator* ( const QSize & size, qreal coeff )

Multiplies size by coeff and returns the result rounded to the nearest integer.

See also QSize::scale().

const QSize operator* ( qreal coeff, const QSize & size )

This is an overloaded member function, provided for convenience. It behaves essentially like the above function.

Multiplies size by coeff and returns the result rounded to the nearest integer.

See also QSize::scale().

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

This is an overloaded member function, provided for convenience. It behaves essentially like the above function.

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

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

This is an overloaded member function, provided for convenience. It behaves essentially like the above function.

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

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

This is an overloaded member function, provided for convenience. It behaves essentially like the above function.

Divides size by divisor and returns the result.

Note that the result is rounded to the nearest integer.

See also QSize::scale().

QDataStream & operator<< ( QDataStream & s, const QSize & sz )

This is an overloaded member function, provided for convenience. It behaves essentially like the above function.

Writes the size sz to the stream s and returns a reference to the stream.

See also Format of the QDataStream operators.

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

This is an overloaded member function, provided for convenience. It behaves essentially like the above function.

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

QDataStream & operator>> ( QDataStream & s, QSize & sz )

This is an overloaded member function, provided for convenience. It behaves essentially like the above function.

Reads the size from the stream s into size sz 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 94
  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. Pourquoi les programmeurs sont-ils moins payés que les gestionnaires de programmes ? Manquent-ils de pouvoir de négociation ? 42
  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 8
Page suivante

Le Qt Developer Network au hasard

Logo

Installation de PySide : binaires et compilation

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