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>
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 | |
PrivateData * | d_data |
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.
QwtDynGridLayout::QwtDynGridLayout | ( | QWidget * | parent, |
int | margin = 0 , |
||
int | spacing = -1 |
||
) | [explicit] |
parent | Parent widget |
margin | Margin |
spacing | Spacing |
Definition at line 58 of file qwt_dyngrid_layout.cpp.
QwtDynGridLayout::QwtDynGridLayout | ( | int | spacing = -1 | ) | [explicit] |
spacing | Spacing |
Definition at line 72 of file qwt_dyngrid_layout.cpp.
QwtDynGridLayout::~QwtDynGridLayout | ( | ) | [virtual] |
Destructor.
Definition at line 90 of file qwt_dyngrid_layout.cpp.
void QwtDynGridLayout::addItem | ( | QLayoutItem * | item | ) | [virtual] |
Add an item to the next free position.
item | Layout 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() )
width | Available width for all columns |
Definition at line 260 of file qwt_dyngrid_layout.cpp.
int QwtDynGridLayout::count | ( | ) | const [virtual] |
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.
Definition at line 215 of file qwt_dyngrid_layout.cpp.
bool QwtDynGridLayout::hasHeightForWidth | ( | ) | const [virtual] |
Definition at line 444 of file qwt_dyngrid_layout.cpp.
int QwtDynGridLayout::heightForWidth | ( | int | width | ) | const [virtual] |
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] |
Definition at line 141 of file qwt_dyngrid_layout.cpp.
QLayoutItem * QwtDynGridLayout::itemAt | ( | int | index | ) | const [virtual] |
Find the item at a specific index
index | Index |
Definition at line 161 of file qwt_dyngrid_layout.cpp.
uint QwtDynGridLayout::itemCount | ( | ) | const |
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.
numColumns | Number of columns. |
rowHeight | Array where to fill in the calculated row heights. |
colWidth | Array 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.
rect | Rect where to place the items |
numColumns | Number of columns |
Definition at line 346 of file qwt_dyngrid_layout.cpp.
uint QwtDynGridLayout::maxColumns | ( | ) | const |
Return the upper limit for the number of columns.
0 means unlimited, what is the default.
Definition at line 123 of file qwt_dyngrid_layout.cpp.
int QwtDynGridLayout::maxItemWidth | ( | ) | const [virtual] |
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.
numColumns | Given number of columns |
itemWidth | Array of the width hints for all items |
Definition at line 289 of file qwt_dyngrid_layout.cpp.
uint QwtDynGridLayout::numColumns | ( | ) | const |
Definition at line 588 of file qwt_dyngrid_layout.cpp.
uint QwtDynGridLayout::numRows | ( | ) | const |
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.
expanding | Or'd orientations |
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.
rect | Layout geometry |
Definition at line 226 of file qwt_dyngrid_layout.cpp.
void QwtDynGridLayout::setMaxColumns | ( | uint | maxColumns | ) |
Limit the number of columns.
maxColumns | upper limit, 0 means unlimited |
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.
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.
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 |
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
index | Index |
Definition at line 176 of file qwt_dyngrid_layout.cpp.
PrivateData* QwtDynGridLayout::d_data [private] |
Definition at line 79 of file qwt_dyngrid_layout.h.