QWT API (English) 7.3.0
Qt Widget Library for Technical Applications - English API Documentation
Loading...
Searching...
No Matches
Classes | Public Member Functions | Protected Member Functions | List of all members
QwtDynGridLayout Class Reference

Dynamic grid layout that adjusts columns and rows to the current size. More...

#include <qwt_dyngrid_layout.h>

Inheritance diagram for QwtDynGridLayout:

Classes

class  PrivateData
 

Public Member Functions

 QwtDynGridLayout (QWidget *, int margin=0, int spacing=-1)
 Constructor with parent widget, margin and spacing.
 
 QwtDynGridLayout (int spacing=-1)
 Constructor with spacing only.
 
 ~QwtDynGridLayout () override
 Destructor.
 
virtual void invalidate () override
 Invalidate all internal caches.
 
void setMaxColumns (uint maxColumns)
 Set the upper limit for the number of columns.
 
uint maxColumns () const
 Get the upper limit for the number of columns.
 
uint numRows () const
 Get the number of rows in the current layout.
 
uint numColumns () const
 Get the number of columns in the current layout.
 
virtual void addItem (QLayoutItem *) override
 Add an item to the next free position.
 
virtual QLayoutItem * itemAt (int index) const override
 Get the item at a specific index.
 
virtual QLayoutItem * takeAt (int index) override
 Remove and return the item at a specific index.
 
virtual int count () const override
 Get the number of items in the layout.
 
void setExpandingDirections (Qt::Orientations)
 Set the expanding directions for the layout.
 
virtual Qt::Orientations expandingDirections () const override
 Get the expanding directions for the layout.
 
QList< QRect > layoutItems (const QRect &, uint numColumns) const
 Calculate the geometries of the layout items.
 
virtual int maxItemWidth () const
 Get the maximum width of all layout items.
 
virtual void setGeometry (const QRect &) override
 Set the geometry for the layout.
 
virtual bool hasHeightForWidth () const override
 Check if the layout has height for width.
 
virtual int heightForWidth (int) const override
 Get the preferred height for a given width.
 
virtual QSize sizeHint () const override
 Get the size hint for the layout.
 
virtual bool isEmpty () const override
 Check if the layout is empty.
 
uint itemCount () const
 Get the number of layout items.
 
virtual uint columnsForWidth (int width) const
 Calculate the number of columns for a given width.
 

Protected Member Functions

void layoutGrid (uint numColumns, QVector< int > &rowHeight, QVector< int > &colWidth) const
 Calculate the dimensions for the columns and rows for a grid of numColumns columns.
 
void stretchGrid (const QRect &rect, uint numColumns, QVector< int > &rowHeight, QVector< int > &colWidth) const
 Stretch columns in case of expanding() & QSizePolicy::Horizontal and rows in case of expanding() & QSizePolicy::Vertical to fill the entire rect.
 

Detailed Description

Dynamic grid layout that adjusts 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() [1/2]

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

Constructor with parent widget, margin and spacing.

Parameters
[in]parentParent widget
[in]marginMargin around the layout
[in]spacingSpacing between items

◆ QwtDynGridLayout() [2/2]

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

Constructor with spacing only.

Parameters
[in]spacingSpacing between items

◆ ~QwtDynGridLayout()

QwtDynGridLayout::~QwtDynGridLayout ( )
override

Destructor.

Deletes all layout items and private data.

Member Function Documentation

◆ addItem()

void QwtDynGridLayout::addItem ( QLayoutItem *  item)
overridevirtual

Add an item to the next free position.

Parameters
[in]itemLayout item to add

◆ 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
[in]widthAvailable width for all columns
Returns
Number of columns for the given width

◆ count()

int QwtDynGridLayout::count ( ) const
overridevirtual

Get the number of items in the layout.

Returns
Number of layout items

◆ expandingDirections()

Qt::Orientations QwtDynGridLayout::expandingDirections ( ) const
overridevirtual

Get the expanding directions for the layout.

Returns
Orientations where the layout expands

◆ hasHeightForWidth()

bool QwtDynGridLayout::hasHeightForWidth ( ) const
overridevirtual

Check if the layout has height for width.

Returns
true, indicating QwtDynGridLayout implements heightForWidth()

◆ heightForWidth()

int QwtDynGridLayout::heightForWidth ( int  width) const
overridevirtual

Get the preferred height for a given width.

Parameters
[in]widthWidth to calculate height for
Returns
Preferred height for the given width

◆ invalidate()

void QwtDynGridLayout::invalidate ( )
overridevirtual

Invalidate all internal caches.

Marks the layout as dirty so it will recalculate on next layout operation.

◆ isEmpty()

bool QwtDynGridLayout::isEmpty ( ) const
overridevirtual

Check if the layout is empty.

Returns
true if the layout contains no items

◆ itemAt()

QLayoutItem * QwtDynGridLayout::itemAt ( int  index) const
overridevirtual

Get the item at a specific index.

Parameters
[in]indexIndex of the item
Returns
Item at the specified index, or nullptr if index is out of range

◆ itemCount()

uint QwtDynGridLayout::itemCount ( ) const

Get the number of layout items.

Returns
Number of items in the layout

◆ 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.

◆ layoutItems()

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

Calculate the geometries of the layout items.

Parameters
[in]rectRectangle where to place the items
[in]numColumnsNumber of columns
Returns
List of item geometries

◆ maxColumns()

uint QwtDynGridLayout::maxColumns ( ) const

Get the upper limit for the number of columns.

Returns
Upper limit for the number of columns, 0 means unlimited

◆ maxItemWidth()

int QwtDynGridLayout::maxItemWidth ( ) const
virtual

Get the maximum width of all layout items.

Returns
Maximum width of all items

◆ numColumns()

uint QwtDynGridLayout::numColumns ( ) const

Get the number of columns in the current layout.

Warning
The number of columns might change whenever the geometry changes.
Returns
Number of columns

◆ numRows()

uint QwtDynGridLayout::numRows ( ) const

Get the number of rows in the current layout.

Warning
The number of rows might change whenever the geometry changes.
Returns
Number of rows

◆ setExpandingDirections()

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

Set the expanding directions for the layout.

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.

Parameters
[in]expandingOr'd orientations

◆ setGeometry()

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

Set the geometry for the layout.

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

Parameters
[in]rectLayout geometry

◆ setMaxColumns()

void QwtDynGridLayout::setMaxColumns ( uint  maxColumns)

Set the upper limit for the number of columns.

Parameters
[in]maxColumnsUpper limit, 0 means unlimited

◆ sizeHint()

QSize QwtDynGridLayout::sizeHint ( ) const
overridevirtual

Get the size hint for the layout.

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

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

◆ takeAt()

QLayoutItem * QwtDynGridLayout::takeAt ( int  index)
overridevirtual

Remove and return the item at a specific index.

Parameters
[in]indexIndex of the item to remove
Returns
Removed item, or nullptr if index is out of range

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