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

QSizePolicy Class Reference

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

#include <qsizepolicy.h>

List of all member functions.

Public Members


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. Only one of the constructors is of interest in most applications.

QSizePolicy contains two independent SizeType objects; 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 SizeTypes are set in the usual constructor and can be queried using a variety of functions.

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

See also QSizePolicy::SizeType, Widget Appearance and Style, and Layout Management.


Member Type Documentation

QSizePolicy::ExpandData

This enum type describes in which directions a widget can make use of extra space. There are four possible values:

  • QSizePolicy::NoDirection - the widget cannot make use of extra space in any direction.
  • QSizePolicy::Horizontally - the widget can usefully be wider than the sizeHint().
  • QSizePolicy::Vertically - the widget can usefully be taller than the sizeHint().
  • QSizePolicy::BothDirections - the widget can usefully be both wider and taller than the sizeHint().

QSizePolicy::SizeType

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

  • QSizePolicy::Fixed - the 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::Minimum - the 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::Maximum - the 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::Preferred - the 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::Expanding - the 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::MinimumExpanding - the 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::Ignored - the sizeHint() is ignored. The widget will get as much space as possible.

Member Function Documentation

QSizePolicy::QSizePolicy ()

Constructs a minimally initialized QSizePolicy.

QSizePolicy::QSizePolicy ( SizeType hor, SizeType ver, bool hfw = FALSE )

This is the constructor normally used to return a value in the overridden QWidget::sizePolicy() function of a QWidget subclass.

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

If hfw is TRUE, the preferred height of the widget is dependent on the width of the widget (for example, a QLabel with line wrapping).

See also horData(), verData(), and hasHeightForWidth().

QSizePolicy::QSizePolicy ( SizeType hor, SizeType ver, uchar horStretch, uchar verStretch, bool hfw = FALSE )

Constructs a QSizePolicy with independent horizontal and vertical sizing types hor and ver, and stretch factors horStretch and verStretch.

If hfw is TRUE, the preferred height of the widget is dependent on the width of the widget.

See also horStretch() and verStretch().

ExpandData QSizePolicy::expanding () const

Returns whether this layout can make use of more space than sizeHint(). A value of Vertical or Horizontal means that it wants to grow in only one dimension, whereas BothDirections means that it wants to grow in both dimensions.

See also mayShrinkHorizontally(), mayGrowHorizontally(), mayShrinkVertically(), and mayGrowVertically().

bool QSizePolicy::hasHeightForWidth () const

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

See also setHeightForWidth().

SizeType QSizePolicy::horData () const

Returns the horizontal component of the size policy.

See also setHorData(), verData(), and horStretch().

uint QSizePolicy::horStretch () const

Returns the horizontal stretch factor of the size policy.

See also setHorStretch() and verStretch().

bool QSizePolicy::mayGrowHorizontally () const

Returns TRUE if the widget can sensibly be wider than its sizeHint(); otherwise returns FALSE.

See also mayGrowVertically() and mayShrinkHorizontally().

bool QSizePolicy::mayGrowVertically () const

Returns TRUE if the widget can sensibly be taller than its sizeHint(); otherwise returns FALSE.

See also mayGrowHorizontally() and mayShrinkVertically().

bool QSizePolicy::mayShrinkHorizontally () const

Returns TRUE if the widget can sensibly be narrower than its sizeHint(); otherwise returns FALSE.

See also mayShrinkVertically() and mayGrowHorizontally().

bool QSizePolicy::mayShrinkVertically () const

Returns TRUE if the widget can sensibly be shorter than its sizeHint(); otherwise returns FALSE.

See also mayShrinkHorizontally() and mayGrowVertically().

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

Returns TRUE if this policy is different from s; otherwise returns FALSE.

See also operator==().

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

Returns TRUE if this policy is equal to s; otherwise returns FALSE.

See also operator!=().

void QSizePolicy::setHeightForWidth ( bool b )

Sets the hasHeightForWidth() flag to b.

See also hasHeightForWidth().

void QSizePolicy::setHorData ( SizeType d )

Sets the horizontal component of the size policy to size type d.

See also horData() and setVerData().

void QSizePolicy::setHorStretch ( uchar sf )

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

See also horStretch() and setVerStretch().

void QSizePolicy::setVerData ( SizeType d )

Sets the vertical component of the size policy to size type d.

See also verData() and setHorData().

void QSizePolicy::setVerStretch ( uchar sf )

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

See also verStretch() and setHorStretch().

void QSizePolicy::transpose ()

Swaps the horizontal and vertical policies and stretches.

SizeType QSizePolicy::verData () const

Returns the vertical component of the size policy.

See also setVerData(), horData(), and verStretch().

uint QSizePolicy::verStretch () const

Returns the vertical stretch factor of the size policy.

See also setVerStretch() and horStretch().


This file is part of the Qt toolkit. Copyright © 1995-2003 Trolltech. All Rights Reserved.

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 85
  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. Pourquoi les programmeurs sont-ils moins payés que les gestionnaires de programmes ? Manquent-ils de pouvoir de négociation ? 19
  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 blog Digia au hasard

Logo

Créer des applications avec un style Metro avec Qt, exemples en QML et C++, un article de Digia Qt traduit par Thibaut Cuvelier

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