Qwt User's Guide 6.1.3

- Main Page
- Classes

- Class List
- Class Index
- Class Hierarchy
- Class Members

Public Member Functions | Protected Member Functions | List of all members
QwtDynGridLayout Class Reference

The QwtDynGridLayout class lays out widgets in a grid, adjusting the number of columns and rows to the current size. More...

`#include <qwt_dyngrid_layout.h>`

Inheritance diagram for QwtDynGridLayout:
[legend]

## Public Member Functions
| QwtDynGridLayout (QWidget *, int margin=0, int space=-1)
| QwtDynGridLayout (int space=-1)
virtual | ~QwtDynGridLayout ()
| Destructor.
virtual void | invalidate ()
| Invalidate all internal caches.
void | setMaxColumns (uint maxCols)
uint | maxColumns () const
| Return the upper limit for the number of columns. More...
uint | numRows () const
uint | numColumns () const
virtual void | addItem (QLayoutItem *)
| Add an item to the next free position. More...
virtual QLayoutItem * | itemAt (int index) const
virtual QLayoutItem * | takeAt (int index)
virtual int | count () const
void | setExpandingDirections (Qt::Orientations)
virtual Qt::Orientations | expandingDirections () const
| Returns whether this layout can make use of more space than sizeHint(). More...
QList< QRect > | layoutItems (const QRect &, uint numCols) const
virtual int | maxItemWidth () const
virtual void | setGeometry (const QRect &rect)
virtual bool | hasHeightForWidth () const
virtual int | heightForWidth (int) const
virtual QSize | sizeHint () const
virtual bool | isEmpty () const
uint | itemCount () const
virtual uint | columnsForWidth (int width) const
| Calculate the number of columns for a given width. More...

## Protected Member Functions
void | layoutGrid (uint numCols, QVector< int > &rowHeight, QVector< int > &colWidth) const
void | stretchGrid (const QRect &rect, uint numCols, QVector< int > &rowHeight, QVector< int > &colWidth) const

## Detailed Description

The QwtDynGridLayout class lays out widgets in a grid, adjusting the number of columns and rows to the current size.

QwtDynGridLayout takes the space it gets, divides it up into rows and columns, and puts each of the widgets it manages into the correct cell(s). It lays out as many number of columns as possible (limited by maxColumns()).

## Constructor & Destructor Documentation

QwtDynGridLayout::QwtDynGridLayout | ( | QWidget * | parent,
|  | int | margin = `0`,
|  | int | spacing = `-1`
| ) |  |
| explicit

Parameters

  parent | Parent widget
  margin | Margin
  spacing | Spacing

QwtDynGridLayout::QwtDynGridLayout | ( | int | spacing = `-1` | ) |
| explicit

Parameters

  spacing | Spacing

## Member Function Documentation

void QwtDynGridLayout::addItem | ( | QLayoutItem * | item | ) |
| virtual

Add an item to the next free position.

Parameters

  item | Layout item

uint QwtDynGridLayout::columnsForWidth | ( | int | width | ) | const
| virtual

Calculate the number of columns for a given width.

The calculation tries to use as many columns as possible ( limited by maxColumns() )

Parameters

  width | Available width for all columns

Returns
  Number of columns for a given width

See also
  maxColumns(), setMaxColumns()

int QwtDynGridLayout::count | ( |  | ) | const
| virtual

Returns
  Number of items in the layout

Qt::Orientations QwtDynGridLayout::expandingDirections | ( |  | ) | const
| virtual

Returns whether this layout can make use of more space than sizeHint().

A value of Qt::Vertical or Qt::Horizontal means that it wants to grow in only one dimension, while Qt::Vertical | Qt::Horizontal means that it wants to grow in both dimensions.

Returns
  Orientations, where the layout expands

See also
  setExpandingDirections()

bool QwtDynGridLayout::hasHeightForWidth | ( |  | ) | const
| virtual

Returns
  true: QwtDynGridLayout implements heightForWidth().

See also
  heightForWidth()

int QwtDynGridLayout::heightForWidth | ( | int | width | ) | const
| virtual

Returns
  The preferred height for this layout, given a width.

See also
  hasHeightForWidth()

bool QwtDynGridLayout::isEmpty | ( |  | ) | const
| virtual

Returns
  true if this layout is empty.

QLayoutItem * QwtDynGridLayout::itemAt | ( | int | index | ) | const
| virtual

Find the item at a specific index

Parameters

  index | Index

Returns
  Item at a specific index

See also
  takeAt()

uint QwtDynGridLayout::itemCount | ( |  | ) | const

Returns
  number of layout items

void QwtDynGridLayout::layoutGrid | ( | uint | numColumns,
|  | QVector< int > & | rowHeight,
|  | QVector< int > & | colWidth
| ) |  | const
| protected

Calculate the dimensions for the columns and rows for a grid of numColumns columns.

Parameters

  numColumns | Number of columns.
  rowHeight | Array where to fill in the calculated row heights.
  colWidth | Array where to fill in the calculated column widths.

QList< QRect > QwtDynGridLayout::layoutItems | ( | const QRect & | rect,
|  | uint | numColumns
| ) |  | const

Calculate the geometries of the layout items for a layout with numColumns columns and a given rectangle.

Parameters

  rect | Rect where to place the items
  numColumns | Number of columns

Returns
  item geometries

uint QwtDynGridLayout::maxColumns | ( |  | ) | const

Return the upper limit for the number of columns.

0 means unlimited, what is the default.

Returns
  Upper limit for the number of columns

See also
  setMaxColumns()

int QwtDynGridLayout::maxItemWidth | ( |  | ) | const
| virtual

Returns
  the maximum width of all layout items

uint QwtDynGridLayout::numColumns | ( |  | ) | const

Returns
  Number of columns of the current layout.

See also
  numRows()

Warning
  The number of columns might change whenever the geometry changes

uint QwtDynGridLayout::numRows | ( |  | ) | const

Returns
  Number of rows of the current layout.

See also
  numColumns()

Warning
  The number of rows might change whenever the geometry changes

void QwtDynGridLayout::setExpandingDirections | ( | Qt::Orientations | expanding | ) |

Set whether this layout can make use of more space than sizeHint(). A value of Qt::Vertical or Qt::Horizontal means that it wants to grow in only one dimension, while Qt::Vertical | Qt::Horizontal means that it wants to grow in both dimensions. The default value is 0.

Parameters

  expanding | Or'd orientations

See also
  expandingDirections()

void QwtDynGridLayout::setGeometry | ( | const QRect & | rect | ) |
| virtual

Reorganizes columns and rows and resizes managed items within a rectangle.

Parameters

  rect | Layout geometry

void QwtDynGridLayout::setMaxColumns | ( | uint | maxColumns | ) |

Limit the number of columns.

Parameters

  maxColumns | upper limit, 0 means unlimited

See also
  maxColumns()

QSize QwtDynGridLayout::sizeHint | ( |  | ) | const
| virtual

Return the size hint. If maxColumns() > 0 it is the size for a grid with maxColumns() columns, otherwise it is the size for a grid with only one row.

Returns
  Size hint

See also
  maxColumns(), setMaxColumns()

void QwtDynGridLayout::stretchGrid | ( | const QRect & | rect,
|  | uint | numColumns,
|  | QVector< int > & | rowHeight,
|  | QVector< int > & | colWidth
| ) |  | const
| protected

Stretch columns in case of expanding() & QSizePolicy::Horizontal and rows in case of expanding() & QSizePolicy::Vertical to fill the entire rect. Rows and columns are stretched with the same factor.

Parameters

  rect | Bounding rectangle
  numColumns | Number of columns
  rowHeight | Array to be filled with the calculated row heights
  colWidth | Array to be filled with the calculated column widths

See also
  setExpanding(), expanding()

QLayoutItem * QwtDynGridLayout::takeAt | ( | int | index | ) |
| virtual

Find the item at a specific index and remove it from the layout

Parameters

  index | Index

Returns
  Layout item, removed from the layout

See also
  itemAt()