Classes | Public Member Functions | Protected Member Functions | Private Member Functions | Private Attributes
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>

List of all members.

Classes

class  PrivateData

Public Member Functions

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

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

Private Member Functions

void init ()
int maxRowWidth (int numCols) const

Private Attributes

PrivateDatad_data

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()).

Definition at line 27 of file qwt_dyngrid_layout.h.


Constructor & Destructor Documentation

QwtDynGridLayout::QwtDynGridLayout ( QWidget *  parent,
int  margin = 0,
int  spacing = -1 
) [explicit]
Parameters:
parentParent widget
marginMargin
spacingSpacing

Definition at line 58 of file qwt_dyngrid_layout.cpp.

QwtDynGridLayout::QwtDynGridLayout ( int  spacing = -1) [explicit]
Parameters:
spacingSpacing

Definition at line 72 of file qwt_dyngrid_layout.cpp.

Destructor.

Definition at line 90 of file qwt_dyngrid_layout.cpp.


Member Function Documentation

void QwtDynGridLayout::addItem ( QLayoutItem *  item) [virtual]

Add an item to the next free position.

Parameters:
itemLayout item

Definition at line 132 of file qwt_dyngrid_layout.cpp.

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:
widthAvailable width for all columns
Returns:
Number of columns for a given width
See also:
maxColumns(), setMaxColumns()

Definition at line 260 of file qwt_dyngrid_layout.cpp.

int QwtDynGridLayout::count ( ) const [virtual]
Returns:
Number of items in the layout

Definition at line 186 of file qwt_dyngrid_layout.cpp.

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()

Definition at line 215 of file qwt_dyngrid_layout.cpp.

bool QwtDynGridLayout::hasHeightForWidth ( ) const [virtual]
Returns:
true: QwtDynGridLayout implements heightForWidth().
See also:
heightForWidth()

Definition at line 444 of file qwt_dyngrid_layout.cpp.

int QwtDynGridLayout::heightForWidth ( int  width) const [virtual]
Returns:
The preferred height for this layout, given a width.
See also:
hasHeightForWidth()

Definition at line 453 of file qwt_dyngrid_layout.cpp.

void QwtDynGridLayout::init ( ) [private]

Initialize the layout with default values.

Definition at line 81 of file qwt_dyngrid_layout.cpp.

void QwtDynGridLayout::invalidate ( ) [virtual]

Invalidate all internal caches.

Definition at line 99 of file qwt_dyngrid_layout.cpp.

bool QwtDynGridLayout::isEmpty ( ) const [virtual]
Returns:
true if this layout is empty.

Definition at line 141 of file qwt_dyngrid_layout.cpp.

QLayoutItem * QwtDynGridLayout::itemAt ( int  index) const [virtual]

Find the item at a specific index

Parameters:
indexIndex
Returns:
Item at a specific index
See also:
takeAt()

Definition at line 161 of file qwt_dyngrid_layout.cpp.

Returns:
number of layout items

Definition at line 149 of file qwt_dyngrid_layout.cpp.

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:
numColumnsNumber of columns.
rowHeightArray where to fill in the calculated row heights.
colWidthArray where to fill in the calculated column widths.

Definition at line 417 of file qwt_dyngrid_layout.cpp.

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:
rectRect where to place the items
numColumnsNumber of columns
Returns:
item geometries

Definition at line 346 of file qwt_dyngrid_layout.cpp.

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()

Definition at line 123 of file qwt_dyngrid_layout.cpp.

int QwtDynGridLayout::maxItemWidth ( ) const [virtual]
Returns:
the maximum width of all layout items

Definition at line 318 of file qwt_dyngrid_layout.cpp.

int QwtDynGridLayout::maxRowWidth ( int  numColumns) const [private]

Calculate the width of a layout for a given number of columns.

Parameters:
numColumnsGiven number of columns
itemWidthArray of the width hints for all items

Definition at line 289 of file qwt_dyngrid_layout.cpp.

Returns:
Number of columns of the current layout.
See also:
numRows()
Warning:
The number of columns might change whenever the geometry changes

Definition at line 588 of file qwt_dyngrid_layout.cpp.

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

Definition at line 578 of file qwt_dyngrid_layout.cpp.

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:
expandingOr'd orientations
See also:
expandingDirections()

Definition at line 200 of file qwt_dyngrid_layout.cpp.

void QwtDynGridLayout::setGeometry ( const QRect &  rect) [virtual]

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

Parameters:
rectLayout geometry

Definition at line 226 of file qwt_dyngrid_layout.cpp.

void QwtDynGridLayout::setMaxColumns ( uint  maxColumns)

Limit the number of columns.

Parameters:
maxColumnsupper limit, 0 means unlimited
See also:
maxColumns()

Definition at line 110 of file qwt_dyngrid_layout.cpp.

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()

Definition at line 544 of file qwt_dyngrid_layout.cpp.

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:
rectBounding rectangle
numColumnsNumber of columns
rowHeightArray to be filled with the calculated row heights
colWidthArray to be filled with the calculated column widths
See also:
setExpanding(), expanding()

Definition at line 487 of file qwt_dyngrid_layout.cpp.

QLayoutItem * QwtDynGridLayout::takeAt ( int  index) [virtual]

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

Parameters:
indexIndex
Returns:
Layout item, removed from the layout
See also:
itemAt()

Definition at line 176 of file qwt_dyngrid_layout.cpp.


Member Data Documentation

Definition at line 79 of file qwt_dyngrid_layout.h.


The documentation for this class was generated from the following files:


plotjuggler
Author(s): Davide Faconti
autogenerated on Fri Sep 1 2017 02:41:57