Home | All Classes | Main Classes | Annotated | Grouped Classes | Functions |

# TQSizePolicy Class Reference

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

`#include <ntqsizepolicy.h>`

List of all member functions.

## Public Members

- enum SizeType { Fixed = 0, Minimum = MayGrow, Maximum = MayShrink, Preferred = MayGrow | MayShrink, MinimumExpanding = MayGrow | ExpMask, Expanding = MayGrow | MayShrink | ExpMask, Ignored = ExpMask }
- enum ExpandData { NoDirection = 0, Horizontally = 1, Vertically = 2, Horizontal = Horizontally, Vertical = Vertically, BothDirections = Horizontally | Vertically }
- TQSizePolicy ()
- TQSizePolicy ( SizeType hor, SizeType ver, bool hfw = FALSE )
- TQSizePolicy ( SizeType hor, SizeType ver, uchar horStretch, uchar verStretch, bool hfw = FALSE )
- SizeType horData () const
- SizeType verData () const
- bool mayShrinkHorizontally () const
- bool mayShrinkVertically () const
- bool mayGrowHorizontally () const
- bool mayGrowVertically () const
- ExpandData expanding () const
- void setHorData ( SizeType d )
- void setVerData ( SizeType d )
- void setHeightForWidth ( bool b )
- bool hasHeightForWidth () const
- bool operator== ( const TQSizePolicy & s ) const
- bool operator!= ( const TQSizePolicy & s ) const
- uint horStretch () const
- uint verStretch () const
- void setHorStretch ( uchar sf )
- void setVerStretch ( uchar sf )
- void transpose ()

## Detailed Description

The TQSizePolicy 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 TQWidget::sizePolicy() return a TQSizePolicy 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.

TQSizePolicy 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 TQSizePolicy::SizeType, Widget Appearance and Style, and Layout Management.

## Member Type Documentation

### TQSizePolicy::ExpandData

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

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

### TQSizePolicy::SizeType

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

- `TQSizePolicy::Fixed` - The TQWidget::sizeHint() is the only acceptable alternative, so the widget can never grow or shrink (e.g. the vertical direction of a push button).
- `TQSizePolicy::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). It cannot be smaller than the size provided by sizeHint().
- `TQSizePolicy::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). It cannot be larger than the size provided by sizeHint().
- `TQSizePolicy::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 TQWidget policy).
- `TQSizePolicy::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).
- `TQSizePolicy::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).
- `TQSizePolicy::Ignored` - the sizeHint() is ignored. The widget will get as much space as possible.

## Member Function Documentation

### TQSizePolicy::TQSizePolicy ()

Constructs a minimally initialized TQSizePolicy.

### TQSizePolicy::TQSizePolicy ( SizeType hor, SizeType ver, bool hfw = FALSE )

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

It constructs a TQSizePolicy 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 TQLabel with line wrapping).

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

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

Constructs a TQSizePolicy 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 TQSizePolicy::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 TQSizePolicy::hasHeightForWidth () const

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

See also setHeightForWidth().

### SizeType TQSizePolicy::horData () const

Returns the horizontal component of the size policy.

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

### uint TQSizePolicy::horStretch () const

Returns the horizontal stretch factor of the size policy.

See also setHorStretch() and verStretch().

### bool TQSizePolicy::mayGrowHorizontally () const

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

See also mayGrowVertically() and mayShrinkHorizontally().

### bool TQSizePolicy::mayGrowVertically () const

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

See also mayGrowHorizontally() and mayShrinkVertically().

### bool TQSizePolicy::mayShrinkHorizontally () const

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

See also mayShrinkVertically() and mayGrowHorizontally().

### bool TQSizePolicy::mayShrinkVertically () const

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

See also mayShrinkHorizontally() and mayGrowVertically().

### bool TQSizePolicy::operator!= ( const TQSizePolicy & s ) const

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

See also operator==().

### bool TQSizePolicy::operator== ( const TQSizePolicy & s ) const

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

See also operator!=().

### void TQSizePolicy::setHeightForWidth ( bool b )

Sets the hasHeightForWidth() flag to b.

See also hasHeightForWidth().

### void TQSizePolicy::setHorData ( SizeType d )

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

See also horData() and setVerData().

### void TQSizePolicy::setHorStretch ( uchar sf )

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

See also horStretch() and setVerStretch().

### void TQSizePolicy::setVerData ( SizeType d )

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

See also verData() and setHorData().

### void TQSizePolicy::setVerStretch ( uchar sf )

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

See also verStretch() and setHorStretch().

### void TQSizePolicy::transpose ()

Swaps the horizontal and vertical policies and stretches.

### SizeType TQSizePolicy::verData () const

Returns the vertical component of the size policy.

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

### uint TQSizePolicy::verStretch () const

Returns the vertical stretch factor of the size policy.

See also setVerStretch() and horStretch().

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