iCub-main
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
QCPLayoutGrid Class Reference

A layout that arranges child elements in a grid. More...

#include <qcustomplot.h>

+ Inheritance diagram for QCPLayoutGrid:

Public Member Functions

 QCPLayoutGrid ()
 Creates an instance of QCPLayoutGrid and sets default values. More...
 
virtual ~QCPLayoutGrid ()
 
int rowCount () const
 Returns the number of rows in the layout. More...
 
int columnCount () const
 Returns the number of columns in the layout. More...
 
QList< double > columnStretchFactors () const
 
QList< double > rowStretchFactors () const
 
int columnSpacing () const
 
int rowSpacing () const
 
void setColumnStretchFactor (int column, double factor)
 Sets the stretch factor of column. More...
 
void setColumnStretchFactors (const QList< double > &factors)
 Sets the stretch factors of all columns. More...
 
void setRowStretchFactor (int row, double factor)
 Sets the stretch factor of row. More...
 
void setRowStretchFactors (const QList< double > &factors)
 Sets the stretch factors of all rows. More...
 
void setColumnSpacing (int pixels)
 Sets the gap that is left blank between columns to pixels. More...
 
void setRowSpacing (int pixels)
 Sets the gap that is left blank between rows to pixels. More...
 
virtual void updateLayout ()
 
virtual int elementCount () const
 Returns the number of elements/cells in the layout. More...
 
virtual QCPLayoutElementelementAt (int index) const
 Returns the element in the cell with the given index. More...
 
virtual QCPLayoutElementtakeAt (int index)
 Removes the element with the given index from the layout and returns it. More...
 
virtual bool take (QCPLayoutElement *element)
 Removes the specified element from the layout and returns true on success. More...
 
virtual QList< QCPLayoutElement * > elements (bool recursive) const
 Returns a list of all child elements in this layout element. More...
 
virtual void simplify ()
 Simplifies the layout by collapsing rows and columns which only contain empty cells. More...
 
virtual QSize minimumSizeHint () const
 Returns the minimum size this layout element (the inner rect) may be compressed to. More...
 
virtual QSize maximumSizeHint () const
 Returns the maximum size this layout element (the inner rect) may be expanded to. More...
 
QCPLayoutElementelement (int row, int column) const
 Returns the element in the cell in row and column. More...
 
bool addElement (int row, int column, QCPLayoutElement *element)
 Adds the element to cell with row and column. More...
 
bool hasElement (int row, int column)
 Returns whether the cell at row and column exists and contains a valid element, i.e. More...
 
void expandTo (int newRowCount, int newColumnCount)
 Expands the layout to have newRowCount rows and newColumnCount columns. More...
 
void insertRow (int newIndex)
 Inserts a new row with empty cells at the row index newIndex. More...
 
void insertColumn (int newIndex)
 Inserts a new column with empty cells at the column index newIndex. More...
 
- Public Member Functions inherited from QCPLayout
 QCPLayout ()
 Creates an instance of QCPLayout and sets default values. More...
 
virtual void update (UpdatePhase phase)
 First calls the QCPLayoutElement::update base class implementation to update the margins on this layout. More...
 
bool removeAt (int index)
 Removes and deletes the element at the provided index. More...
 
bool remove (QCPLayoutElement *element)
 Removes and deletes the provided element. More...
 
void clear ()
 Removes and deletes all layout elements in this layout. More...
 
- Public Member Functions inherited from QCPLayoutElement
 QCPLayoutElement (QCustomPlot *parentPlot=0)
 Creates an instance of QCPLayoutElement and sets default values. More...
 
virtual ~QCPLayoutElement ()
 
QCPLayoutlayout () const
 Returns the parent layout of this layout element. More...
 
QRect rect () const
 Returns the inner rect of this layout element. More...
 
QRect outerRect () const
 
QMargins margins () const
 
QMargins minimumMargins () const
 
QCP::MarginSides autoMargins () const
 
QSize minimumSize () const
 
QSize maximumSize () const
 
QCPMarginGroupmarginGroup (QCP::MarginSide side) const
 
QHash< QCP::MarginSide, QCPMarginGroup * > marginGroups () const
 
void setOuterRect (const QRect &rect)
 Sets the outer rect of this layout element. More...
 
void setMargins (const QMargins &margins)
 Sets the margins of this layout element. More...
 
void setMinimumMargins (const QMargins &margins)
 If setAutoMargins is enabled on some or all margins, this function is used to provide minimum values for those margins. More...
 
void setAutoMargins (QCP::MarginSides sides)
 Sets on which sides the margin shall be calculated automatically. More...
 
void setMinimumSize (const QSize &size)
 Sets the minimum size for the inner rect of this layout element. More...
 
void setMinimumSize (int width, int height)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.Sets the minimum size for the inner rect of this layout element. More...
 
void setMaximumSize (const QSize &size)
 Sets the maximum size for the inner rect of this layout element. More...
 
void setMaximumSize (int width, int height)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.Sets the maximum size for the inner rect of this layout element. More...
 
void setMarginGroup (QCP::MarginSides sides, QCPMarginGroup *group)
 Sets the margin group of the specified margin sides. More...
 
virtual double selectTest (const QPointF &pos, bool onlySelectable, QVariant *details=0) const
 Layout elements are sensitive to events inside their outer rect. More...
 
- Public Member Functions inherited from QCPLayerable
 QCPLayerable (QCustomPlot *plot, QString targetLayer="", QCPLayerable *parentLayerable=0)
 Creates a new QCPLayerable instance. More...
 
 ~QCPLayerable ()
 
bool visible () const
 
QCustomPlotparentPlot () const
 
QCPLayerableparentLayerable () const
 Returns the parent layerable of this layerable. More...
 
QCPLayerlayer () const
 
bool antialiased () const
 
void setVisible (bool on)
 Sets the visibility of this layerable object. More...
 
Q_SLOT bool setLayer (QCPLayer *layer)
 Sets the layer of this layerable object. More...
 
bool setLayer (const QString &layerName)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. Sets the layer of this layerable object by name. More...
 
void setAntialiased (bool enabled)
 Sets whether this object will be drawn antialiased or not. More...
 
bool realVisibility () const
 Returns whether this layerable is visible, taking the visibility of the layerable parent and the visibility of the layer this layerable is on into account. More...
 

Protected Member Functions

void getMinimumRowColSizes (QVector< int > *minColWidths, QVector< int > *minRowHeights) const
 
void getMaximumRowColSizes (QVector< int > *maxColWidths, QVector< int > *maxRowHeights) const
 
- Protected Member Functions inherited from QCPLayout
void sizeConstraintsChanged () const
 Subclasses call this method to report changed (minimum/maximum) size constraints. More...
 
void adoptElement (QCPLayoutElement *el)
 
void releaseElement (QCPLayoutElement *el)
 
QVector< int > getSectionSizes (QVector< int > maxSizes, QVector< int > minSizes, QVector< double > stretchFactors, int totalSize) const
 
- Protected Member Functions inherited from QCPLayoutElement
virtual int calculateAutoMargin (QCP::MarginSide side)
 
virtual void mousePressEvent (QMouseEvent *event)
 This event is called, if the mouse was pressed while being inside the outer rect of this layout element. More...
 
virtual void mouseMoveEvent (QMouseEvent *event)
 This event is called, if the mouse is moved inside the outer rect of this layout element. More...
 
virtual void mouseReleaseEvent (QMouseEvent *event)
 This event is called, if the mouse was previously pressed inside the outer rect of this layout element and is now released. More...
 
virtual void mouseDoubleClickEvent (QMouseEvent *event)
 This event is called, if the mouse is double-clicked inside the outer rect of this layout element. More...
 
virtual void wheelEvent (QWheelEvent *event)
 This event is called, if the mouse wheel is scrolled while the cursor is inside the rect of this layout element. More...
 
virtual void applyDefaultAntialiasingHint (QCPPainter *painter) const
 
virtual void draw (QCPPainter *painter)
 
virtual void parentPlotInitialized (QCustomPlot *parentPlot)
 
- Protected Member Functions inherited from QCPLayerable
virtual QCP::Interaction selectionCategory () const
 
virtual QRect clipRect () const
 
virtual void selectEvent (QMouseEvent *event, bool additive, const QVariant &details, bool *selectionStateChanged)
 
virtual void deselectEvent (bool *selectionStateChanged)
 
void initializeParentPlot (QCustomPlot *parentPlot)
 
void setParentLayerable (QCPLayerable *parentLayerable)
 
bool moveToLayer (QCPLayer *layer, bool prepend)
 
void applyAntialiasingHint (QCPPainter *painter, bool localAntialiased, QCP::AntialiasedElement overrideElement) const
 

Protected Attributes

QList< QList< QCPLayoutElement * > > mElements
 
QList< double > mColumnStretchFactors
 
QList< double > mRowStretchFactors
 
int mColumnSpacing
 
int mRowSpacing
 
- Protected Attributes inherited from QCPLayoutElement
QCPLayoutmParentLayout
 
QSize mMinimumSize
 
QSize mMaximumSize
 
QRect mRect
 
QRect mOuterRect
 
QMargins mMargins
 
QMargins mMinimumMargins
 
QCP::MarginSides mAutoMargins
 
QHash< QCP::MarginSide, QCPMarginGroup * > mMarginGroups
 
- Protected Attributes inherited from QCPLayerable
bool mVisible
 
QCustomPlotmParentPlot
 
QPointer< QCPLayerablemParentLayerable
 
QCPLayermLayer
 
bool mAntialiased
 

Additional Inherited Members

- Public Types inherited from QCPLayoutElement
enum  UpdatePhase {
  upPreparation ,
  upMargins ,
  upLayout
}
 Defines the phases of the update process, that happens just before a replot. More...
 
- Signals inherited from QCPLayerable
void layerChanged (QCPLayer *newLayer)
 This signal is emitted when the layer of this layerable changes, i.e. More...
 

Detailed Description

A layout that arranges child elements in a grid.

Elements are laid out in a grid with configurable stretch factors (setColumnStretchFactor, setRowStretchFactor) and spacing (setColumnSpacing, setRowSpacing).

Elements can be added to cells via addElement. The grid is expanded if the specified row or column doesn't exist yet. Whether a cell contains a valid layout element can be checked with hasElement, that element can be retrieved with element. If rows and columns that only have empty cells shall be removed, call simplify. Removal of elements is either done by just adding the element to a different layout or by using the QCPLayout interface take or remove.

Row and column insertion can be performed with insertRow and insertColumn.

Definition at line 756 of file qcustomplot.h.

Constructor & Destructor Documentation

◆ QCPLayoutGrid()

QCPLayoutGrid::QCPLayoutGrid ( )
explicit

Creates an instance of QCPLayoutGrid and sets default values.

Definition at line 2615 of file qcustomplot.cpp.

◆ ~QCPLayoutGrid()

QCPLayoutGrid::~QCPLayoutGrid ( )
virtual

Definition at line 2621 of file qcustomplot.cpp.

Member Function Documentation

◆ addElement()

bool QCPLayoutGrid::addElement ( int  row,
int  column,
QCPLayoutElement element 
)

Adds the element to cell with row and column.

If element is already in a layout, it is first removed from there. If row or column don't exist yet, the layout is expanded accordingly.

Returns true if the element was added successfully, i.e. if the cell at row and column didn't already have an element.

See also
element, hasElement, take, remove

Definition at line 2686 of file qcustomplot.cpp.

◆ columnCount()

int QCPLayoutGrid::columnCount ( ) const

Returns the number of columns in the layout.

See also
rowCount

Definition at line 2668 of file qcustomplot.cpp.

◆ columnSpacing()

int QCPLayoutGrid::columnSpacing ( ) const
inline

Definition at line 776 of file qcustomplot.h.

◆ columnStretchFactors()

QList<double> QCPLayoutGrid::columnStretchFactors ( ) const
inline

Definition at line 774 of file qcustomplot.h.

◆ element()

QCPLayoutElement * QCPLayoutGrid::element ( int  row,
int  column 
) const

Returns the element in the cell in row and column.

Returns 0 if either the row/column is invalid or if the cell is empty. In those cases, a qDebug message is printed. To check whether a cell exists and isn't empty, use hasElement.

See also
addElement, hasElement

Definition at line 2636 of file qcustomplot.cpp.

◆ elementAt()

QCPLayoutElement * QCPLayoutGrid::elementAt ( int  index) const
virtual

Returns the element in the cell with the given index.

If index is invalid, returns 0.

Note that even if index is valid, the respective cell may be empty in some layouts (e.g. QCPLayoutGrid), so this function may return 0 in those cases. You may use this function to check whether a cell is empty or not.

See also
elements, elementCount, takeAt

Implements QCPLayout.

Definition at line 2960 of file qcustomplot.cpp.

◆ elementCount()

int QCPLayoutGrid::elementCount ( ) const
virtual

Returns the number of elements/cells in the layout.

See also
elements, elementAt

Implements QCPLayout.

Definition at line 2954 of file qcustomplot.cpp.

◆ elements()

QList< QCPLayoutElement * > QCPLayoutGrid::elements ( bool  recursive) const
virtual

Returns a list of all child elements in this layout element.

If recursive is true, all sub-child elements are included in the list, too.

Warning
There may be entries with value 0 in the returned list. (For example, QCPLayoutGrid may have empty cells which yield 0 at the respective index.)

Reimplemented from QCPLayout.

Definition at line 3003 of file qcustomplot.cpp.

◆ expandTo()

void QCPLayoutGrid::expandTo ( int  newRowCount,
int  newColumnCount 
)

Expands the layout to have newRowCount rows and newColumnCount columns.

So the last valid row index will be newRowCount-1, the last valid column index will be newColumnCount-1.

If the current column/row count is already larger or equal to newColumnCount/newRowCount, this function does nothing in that dimension.

Newly created cells are empty, new rows and columns have the stretch factor 1.

Note that upon a call to addElement, the layout is expanded automatically to contain the specified row and column, using this function.

See also
simplify

Definition at line 2855 of file qcustomplot.cpp.

◆ getMaximumRowColSizes()

void QCPLayoutGrid::getMaximumRowColSizes ( QVector< int > *  maxColWidths,
QVector< int > *  maxRowHeights 
) const
protected

Definition at line 3154 of file qcustomplot.cpp.

◆ getMinimumRowColSizes()

void QCPLayoutGrid::getMinimumRowColSizes ( QVector< int > *  minColWidths,
QVector< int > *  minRowHeights 
) const
protected

Definition at line 3120 of file qcustomplot.cpp.

◆ hasElement()

bool QCPLayoutGrid::hasElement ( int  row,
int  column 
)

Returns whether the cell at row and column exists and contains a valid element, i.e.

isn't empty.

See also
element

Definition at line 2711 of file qcustomplot.cpp.

◆ insertColumn()

void QCPLayoutGrid::insertColumn ( int  newIndex)

Inserts a new column with empty cells at the column index newIndex.

Valid values for newIndex range from 0 (inserts a row at the left) to rowCount (appends a row at the right).

See also
insertRow

Definition at line 2906 of file qcustomplot.cpp.

◆ insertRow()

void QCPLayoutGrid::insertRow ( int  newIndex)

Inserts a new row with empty cells at the row index newIndex.

Valid values for newIndex range from 0 (inserts a row at the top) to rowCount (appends a row at the bottom).

See also
insertColumn

Definition at line 2880 of file qcustomplot.cpp.

◆ maximumSizeHint()

QSize QCPLayoutGrid::maximumSizeHint ( ) const
virtual

Returns the maximum size this layout element (the inner rect) may be expanded to.

if a maximum size (setMaximumSize) was not set manually, parent layouts consult this function to determine the maximum allowed size of this layout element. (A manual maximum size is considered set if it is smaller than Qt's QWIDGETSIZE_MAX.)

Reimplemented from QCPLayoutElement.

Definition at line 3093 of file qcustomplot.cpp.

◆ minimumSizeHint()

QSize QCPLayoutGrid::minimumSizeHint ( ) const
virtual

Returns the minimum size this layout element (the inner rect) may be compressed to.

if a minimum size (setMinimumSize) was not set manually, parent layouts consult this function to determine the minimum allowed size of this layout element. (A manual minimum size is considered set if it is non-zero.)

Reimplemented from QCPLayoutElement.

Definition at line 3078 of file qcustomplot.cpp.

◆ rowCount()

int QCPLayoutGrid::rowCount ( ) const

Returns the number of rows in the layout.

See also
columnCount

Definition at line 2658 of file qcustomplot.cpp.

◆ rowSpacing()

int QCPLayoutGrid::rowSpacing ( ) const
inline

Definition at line 777 of file qcustomplot.h.

◆ rowStretchFactors()

QList<double> QCPLayoutGrid::rowStretchFactors ( ) const
inline

Definition at line 775 of file qcustomplot.h.

◆ setColumnSpacing()

void QCPLayoutGrid::setColumnSpacing ( int  pixels)

Sets the gap that is left blank between columns to pixels.

See also
setRowSpacing

Definition at line 2826 of file qcustomplot.cpp.

◆ setColumnStretchFactor()

void QCPLayoutGrid::setColumnStretchFactor ( int  column,
double  factor 
)

Sets the stretch factor of column.

Stretch factors control the relative sizes of rows and columns. Cells will not be resized beyond their minimum and maximum widths/heights (QCPLayoutElement::setMinimumSize, QCPLayoutElement::setMaximumSize), regardless of the stretch factor.

The default stretch factor of newly created rows/columns is 1.

See also
setColumnStretchFactors, setRowStretchFactor

Definition at line 2730 of file qcustomplot.cpp.

◆ setColumnStretchFactors()

void QCPLayoutGrid::setColumnStretchFactors ( const QList< double > &  factors)

Sets the stretch factors of all columns.

factors must have the size columnCount.

Stretch factors control the relative sizes of rows and columns. Cells will not be resized beyond their minimum and maximum widths/heights (QCPLayoutElement::setMinimumSize, QCPLayoutElement::setMaximumSize), regardless of the stretch factor.

The default stretch factor of newly created rows/columns is 1.

See also
setColumnStretchFactor, setRowStretchFactors

Definition at line 2753 of file qcustomplot.cpp.

◆ setRowSpacing()

void QCPLayoutGrid::setRowSpacing ( int  pixels)

Sets the gap that is left blank between rows to pixels.

See also
setColumnSpacing

Definition at line 2836 of file qcustomplot.cpp.

◆ setRowStretchFactor()

void QCPLayoutGrid::setRowStretchFactor ( int  row,
double  factor 
)

Sets the stretch factor of row.

Stretch factors control the relative sizes of rows and columns. Cells will not be resized beyond their minimum and maximum widths/heights (QCPLayoutElement::setMinimumSize, QCPLayoutElement::setMaximumSize), regardless of the stretch factor.

The default stretch factor of newly created rows/columns is 1.

See also
setColumnStretchFactors, setRowStretchFactor

Definition at line 2781 of file qcustomplot.cpp.

◆ setRowStretchFactors()

void QCPLayoutGrid::setRowStretchFactors ( const QList< double > &  factors)

Sets the stretch factors of all rows.

factors must have the size rowCount.

Stretch factors control the relative sizes of rows and columns. Cells will not be resized beyond their minimum and maximum widths/heights (QCPLayoutElement::setMinimumSize, QCPLayoutElement::setMaximumSize), regardless of the stretch factor.

The default stretch factor of newly created rows/columns is 1.

See also
setRowStretchFactor, setColumnStretchFactors

Definition at line 2804 of file qcustomplot.cpp.

◆ simplify()

void QCPLayoutGrid::simplify ( )
virtual

Simplifies the layout by collapsing rows and columns which only contain empty cells.

Reimplemented from QCPLayout.

Definition at line 3033 of file qcustomplot.cpp.

◆ take()

bool QCPLayoutGrid::take ( QCPLayoutElement element)
virtual

Removes the specified element from the layout and returns true on success.

If the element isn't in this layout, returns false.

Note that some layouts don't remove the respective cell right away but leave an empty cell after successful removal of the layout element. To collapse empty cells, use simplify.

See also
takeAt

Implements QCPLayout.

Definition at line 2984 of file qcustomplot.cpp.

◆ takeAt()

QCPLayoutElement * QCPLayoutGrid::takeAt ( int  index)
virtual

Removes the element with the given index from the layout and returns it.

If the index is invalid or the cell with that index is empty, returns 0.

Note that some layouts don't remove the respective cell right away but leave an empty cell after successful removal of the layout element. To collapse empty cells, use simplify.

See also
elementAt, take

Implements QCPLayout.

Definition at line 2969 of file qcustomplot.cpp.

◆ updateLayout()

void QCPLayoutGrid::updateLayout ( )
virtual

Reimplemented from QCPLayout.

Definition at line 2925 of file qcustomplot.cpp.

Member Data Documentation

◆ mColumnSpacing

int QCPLayoutGrid::mColumnSpacing
protected

Definition at line 811 of file qcustomplot.h.

◆ mColumnStretchFactors

QList<double> QCPLayoutGrid::mColumnStretchFactors
protected

Definition at line 809 of file qcustomplot.h.

◆ mElements

QList<QList<QCPLayoutElement*> > QCPLayoutGrid::mElements
protected

Definition at line 808 of file qcustomplot.h.

◆ mRowSpacing

int QCPLayoutGrid::mRowSpacing
protected

Definition at line 811 of file qcustomplot.h.

◆ mRowStretchFactors

QList<double> QCPLayoutGrid::mRowStretchFactors
protected

Definition at line 810 of file qcustomplot.h.


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