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  · 

QSizePolicy Class Reference
[QtGui module]

The QSizePolicy class is a layout attribute describing horizontal and vertical resizing policy. More...

#include <QSizePolicy>

Public Types

  • enum Policy { Fixed, Minimum, Maximum, Preferred, ..., Ignored }
  • enum PolicyFlag { GrowFlag, ExpandFlag, ShrinkFlag, IgnoreFlag }

Public Functions


Detailed Description

The QSizePolicy class is a layout attribute describing horizontal and vertical resizing policy.

The size policy of a widget is an expression of its willingness to be resized in various ways.

Widgets that reimplement QWidget::sizePolicy() return a QSizePolicy that describes the horizontal and vertical resizing policy they prefer when being laid out.

QSizePolicy contains two independent QSizePolicy::Policy values and two stretch factors; one describes the widgets's horizontal size policy, and the other describes its vertical size policy. It also contains a flag to indicate whether the height and width of its preferred size are related.

The horizontal and vertical policies are set in the usual constructor and can be queried using horizontalPolicy() and verticalPolicy().

The hasHeightForWidth() flag indicates whether the widget's sizeHint() is width-dependent (such as a menu bar or a word-wrapping label).

See also QSize, QWidget::sizeHint(), QWidget::sizePolicy(), and QLayoutItem::sizeHint().


Member Type Documentation

enum QSizePolicy::Policy

The per-dimension sizing types used when constructing a QSizePolicy are:

ConstantValueDescription
QSizePolicy::Fixed0The QWidget::sizeHint() is the only acceptable alternative, so the widget can never grow or shrink (e.g. the vertical direction of a push button).
QSizePolicy::MinimumGrowFlagThe sizeHint() is minimal, and sufficient. The widget can be expanded, but there is no advantage to it being larger (e.g. the horizontal direction of a push button).
QSizePolicy::MaximumShrinkFlagThe sizeHint() is a maximum. The widget can be shrunk any amount without detriment if other widgets need the space (e.g. a separator line).
QSizePolicy::PreferredGrowFlag | ShrinkFlagThe sizeHint() is best, but the widget can be shrunk and still be useful. The widget can be expanded, but there is no advantage to it being larger than sizeHint() (the default QWidget policy).
QSizePolicy::ExpandingGrowFlag | ShrinkFlag | ExpandFlagThe sizeHint() is a sensible size, but the widget can be shrunk and still be useful. The widget can make use of extra space, so it should get as much space as possible (e.g. the horizontal direction of a slider).
QSizePolicy::MinimumExpandingGrowFlag | ExpandFlagThe sizeHint() is minimal, and sufficient. The widget can make use of extra space, so it should get as much space as possible (e.g. the horizontal direction of a slider).
QSizePolicy::IgnoredShrinkFlag | GrowFlag | IgnoreFlagThe sizeHint() is ignored. The widget will get as much space as possible.

See also PolicyFlag.

enum QSizePolicy::PolicyFlag

These flags are combined together to form the various Policy values:

ConstantValueDescription
QSizePolicy::GrowFlag1The widget can grow beyond its size hint if necessary.
QSizePolicy::ExpandFlag2The widget should get as much space as possible.
QSizePolicy::ShrinkFlag4The widget can shrink below its size hint if necessary.
QSizePolicy::IgnoreFlag8The widget's size hint is ignored. The widget will get as much space as possible.

See also Policy.


Member Function Documentation

QSizePolicy::QSizePolicy ()

Constructs a QSizePolicy with Fixed as its horizontal and vertical policies.

See also setHorizontalPolicy(), setVerticalPolicy(), setHorizontalStretch(), setVerticalStretch(), and setHeightForWidth().

QSizePolicy::QSizePolicy ( Policy horizontal, Policy vertical )

It constructs a QSizePolicy with independent horizontal and vertical policies, horizontal and vertical respectively. These policies affect how the widget is treated by the layout engine.

Use setHeightForWidth() if the preferred height of the widget is dependent on the width of the widget (for example, a QLabel with line wrapping).

See also horizontalPolicy(), verticalPolicy(), and setHeightForWidth().

Qt::Orientations QSizePolicy::expandingDirections () const

Returns whether this widget can make use of more space than sizeHint(). A value of Qt::Horizontal or Qt::Vertical means that the widget wants to grow horizontally or vertically (i.e., the horizontal or vertical policy is Expanding or MinimumExpanding), whereas Qt::Horizontal | Qt::Vertical means that it wants to grow in both dimensions.

See also horizontalPolicy() and verticalPolicy().

bool QSizePolicy::hasHeightForWidth () const

Returns true if the widget's preferred height depends on its width; otherwise returns false.

See also setHeightForWidth().

Policy QSizePolicy::horizontalPolicy () const

Returns the horizontal component of the size policy.

See also setHorizontalPolicy(), verticalPolicy(), and horizontalStretch().

int QSizePolicy::horizontalStretch () const

Returns the horizontal stretch factor of the size policy.

See also setHorizontalStretch() and verticalStretch().

void QSizePolicy::setHeightForWidth ( bool hfw )

Sets the hasHeightForWidth() flag to hfw.

See also hasHeightForWidth().

void QSizePolicy::setHorizontalPolicy ( Policy policy )

Sets the horizontal component of the size policy to policy.

See also horizontalPolicy() and setVerticalPolicy().

void QSizePolicy::setHorizontalStretch ( uchar stretch )

Sets the horizontal stretch factor of the size policy to stretch.

See also horizontalStretch() and setVerticalStretch().

void QSizePolicy::setVerticalPolicy ( Policy policy )

Sets the vertical component of the size policy to policy.

See also verticalPolicy() and setHorizontalPolicy().

void QSizePolicy::setVerticalStretch ( uchar stretch )

Sets the vertical stretch factor of the size policy to stretch.

See also verticalStretch() and setHorizontalStretch().

void QSizePolicy::transpose ()

Swaps the horizontal and vertical policies and stretches.

Policy QSizePolicy::verticalPolicy () const

Returns the vertical component of the size policy.

See also setVerticalPolicy(), horizontalPolicy(), and verticalStretch().

int QSizePolicy::verticalStretch () const

Returns the vertical stretch factor of the size policy.

See also setVerticalStretch() and horizontalStretch().

QSizePolicy::operator QVariant () const

Returns a QVariant storing this QSizePolicy.

bool QSizePolicy::operator!= ( const QSizePolicy & other ) const

Returns true if this policy is different from other; otherwise returns false.

See also operator==().

bool QSizePolicy::operator== ( const QSizePolicy & other ) const

Returns true if this policy is equal to other; otherwise returns false.

See also operator!=().

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 53
  2. Les développeurs ignorent-ils trop les failles découvertes dans leur code ? Prenez-vous en compte les remarques des autres ? 17
  3. 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
  4. Apercevoir la troisième dimension ou l'utilisation multithreadée d'OpenGL dans Qt, un article des Qt Quarterly traduit par Guillaume Belz 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 blog Digia au hasard

Logo

Déploiement d'applications Qt Commercial sur les tablettes Windows 8

Le blog Digia est l'endroit privilégié pour la communication sur l'édition commerciale de Qt, où des réponses publiques sont apportées aux questions les plus posées au support. 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