Classes | Public Member Functions | Protected Member Functions | Private Member Functions | Private Attributes | 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:
Inheritance graph
[legend]

Classes

class  PrivateData
 

Public Member Functions

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

Protected Member Functions

void layoutGrid (uint numColumns, QVector< int > &rowHeight, QVector< int > &colWidth) const
 
void stretchGrid (const QRect &rect, uint numColumns, QVector< int > &rowHeight, QVector< int > &colWidth) const
 

Private Member Functions

void init ()
 
int maxRowWidth (int numColumns) const
 

Private Attributes

PrivateDatam_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() [1/2]

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() [2/2]

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

Definition at line 71 of file qwt_dyngrid_layout.cpp.

◆ ~QwtDynGridLayout()

QwtDynGridLayout::~QwtDynGridLayout ( )
virtual

Destructor.

Definition at line 88 of file qwt_dyngrid_layout.cpp.

Member Function Documentation

◆ addItem()

void QwtDynGridLayout::addItem ( QLayoutItem *  item)
virtual

Add an item to the next free position.

Parameters
itemLayout item

Definition at line 128 of file qwt_dyngrid_layout.cpp.

◆ columnsForWidth()

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 256 of file qwt_dyngrid_layout.cpp.

◆ count()

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

Definition at line 182 of file qwt_dyngrid_layout.cpp.

◆ expandingDirections()

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 211 of file qwt_dyngrid_layout.cpp.

◆ hasHeightForWidth()

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

Definition at line 446 of file qwt_dyngrid_layout.cpp.

◆ heightForWidth()

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

Definition at line 455 of file qwt_dyngrid_layout.cpp.

◆ init()

void QwtDynGridLayout::init ( )
private

Initialize the layout with default values.

Definition at line 80 of file qwt_dyngrid_layout.cpp.

◆ invalidate()

void QwtDynGridLayout::invalidate ( )
virtual

Invalidate all internal caches.

Definition at line 95 of file qwt_dyngrid_layout.cpp.

◆ isEmpty()

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

Definition at line 137 of file qwt_dyngrid_layout.cpp.

◆ itemAt()

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 157 of file qwt_dyngrid_layout.cpp.

◆ itemCount()

uint QwtDynGridLayout::itemCount ( ) const
Returns
number of layout items

Definition at line 145 of file qwt_dyngrid_layout.cpp.

◆ layoutGrid()

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 419 of file qwt_dyngrid_layout.cpp.

◆ layoutItems()

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 344 of file qwt_dyngrid_layout.cpp.

◆ maxColumns()

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

Definition at line 119 of file qwt_dyngrid_layout.cpp.

◆ maxItemWidth()

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

Definition at line 316 of file qwt_dyngrid_layout.cpp.

◆ maxRowWidth()

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 285 of file qwt_dyngrid_layout.cpp.

◆ numColumns()

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

Definition at line 596 of file qwt_dyngrid_layout.cpp.

◆ numRows()

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 586 of file qwt_dyngrid_layout.cpp.

◆ setExpandingDirections()

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 196 of file qwt_dyngrid_layout.cpp.

◆ setGeometry()

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

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

Parameters
rectLayout geometry

Definition at line 222 of file qwt_dyngrid_layout.cpp.

◆ setMaxColumns()

void QwtDynGridLayout::setMaxColumns ( uint  maxColumns)

Limit the number of columns.

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

Definition at line 106 of file qwt_dyngrid_layout.cpp.

◆ sizeHint()

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 550 of file qwt_dyngrid_layout.cpp.

◆ stretchGrid()

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 491 of file qwt_dyngrid_layout.cpp.

◆ takeAt()

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 172 of file qwt_dyngrid_layout.cpp.

Member Data Documentation

◆ m_data

PrivateData* QwtDynGridLayout::m_data
private

Definition at line 80 of file qwt_dyngrid_layout.h.


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


plotjuggler
Author(s): Davide Faconti
autogenerated on Sun Aug 11 2024 02:24:29