iCub-main
Loading...
Searching...
No Matches
Public Member Functions | Protected Member Functions | Friends | List of all members
QCPLayout Class Referenceabstract

The abstract base class for layouts. More...

#include <qcustomplot.h>

+ Inheritance diagram for QCPLayout:

Public Member Functions

 QCPLayout ()
 Creates an instance of QCPLayout and sets default values.
 
virtual void update (UpdatePhase phase)
 First calls the QCPLayoutElement::update base class implementation to update the margins on this layout.
 
virtual QList< QCPLayoutElement * > elements (bool recursive) const
 Returns a list of all child elements in this layout element.
 
virtual int elementCount () const =0
 Returns the number of elements/cells in the layout.
 
virtual QCPLayoutElementelementAt (int index) const =0
 Returns the element in the cell with the given index.
 
virtual QCPLayoutElementtakeAt (int index)=0
 Removes the element with the given index from the layout and returns it.
 
virtual bool take (QCPLayoutElement *element)=0
 Removes the specified element from the layout and returns true on success.
 
virtual void simplify ()
 Simplifies the layout by collapsing empty cells.
 
bool removeAt (int index)
 Removes and deletes the element at the provided index.
 
bool remove (QCPLayoutElement *element)
 Removes and deletes the provided element.
 
void clear ()
 Removes and deletes all layout elements in this layout.
 
- Public Member Functions inherited from QCPLayoutElement
 QCPLayoutElement (QCustomPlot *parentPlot=0)
 Creates an instance of QCPLayoutElement and sets default values.
 
virtual ~QCPLayoutElement ()
 
QCPLayoutlayout () const
 Returns the parent layout of this layout element.
 
QRect rect () const
 Returns the inner rect of this layout element.
 
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.
 
void setMargins (const QMargins &margins)
 Sets the margins of this layout element.
 
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.
 
void setAutoMargins (QCP::MarginSides sides)
 Sets on which sides the margin shall be calculated automatically.
 
void setMinimumSize (const QSize &size)
 Sets the minimum size for the inner rect of this layout element.
 
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.
 
void setMaximumSize (const QSize &size)
 Sets the maximum size for the inner rect of this layout element.
 
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.
 
void setMarginGroup (QCP::MarginSides sides, QCPMarginGroup *group)
 Sets the margin group of the specified margin sides.
 
virtual QSize minimumSizeHint () const
 Returns the minimum size this layout element (the inner rect) may be compressed to.
 
virtual QSize maximumSizeHint () const
 Returns the maximum size this layout element (the inner rect) may be expanded to.
 
virtual double selectTest (const QPointF &pos, bool onlySelectable, QVariant *details=0) const
 Layout elements are sensitive to events inside their outer rect.
 
- Public Member Functions inherited from QCPLayerable
 QCPLayerable (QCustomPlot *plot, QString targetLayer="", QCPLayerable *parentLayerable=0)
 Creates a new QCPLayerable instance.
 
 ~QCPLayerable ()
 
bool visible () const
 
QCustomPlotparentPlot () const
 
QCPLayerableparentLayerable () const
 Returns the parent layerable of this layerable.
 
QCPLayerlayer () const
 
bool antialiased () const
 
void setVisible (bool on)
 Sets the visibility of this layerable object.
 
Q_SLOT bool setLayer (QCPLayer *layer)
 Sets the layer of this layerable object.
 
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.
 
void setAntialiased (bool enabled)
 Sets whether this object will be drawn antialiased or not.
 
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.
 

Protected Member Functions

virtual void updateLayout ()
 
void sizeConstraintsChanged () const
 Subclasses call this method to report changed (minimum/maximum) size constraints.
 
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.
 
virtual void mouseMoveEvent (QMouseEvent *event)
 This event is called, if the mouse is moved inside the outer rect of this layout element.
 
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.
 
virtual void mouseDoubleClickEvent (QMouseEvent *event)
 This event is called, if the mouse is double-clicked inside the outer rect of this layout element.
 
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.
 
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
 

Friends

class QCPLayoutElement
 

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

Detailed Description

The abstract base class for layouts.

This is an abstract base class for layout elements whose main purpose is to define the position and size of other child layout elements. In most cases, layouts don't draw anything themselves (but there are exceptions to this, e.g. QCPLegend).

QCPLayout derives from QCPLayoutElement, and thus can itself be nested in other layouts.

QCPLayout introduces a common interface for accessing and manipulating the child elements. Those functions are most notably elementCount, elementAt, takeAt, take, simplify, removeAt, remove and clear. Individual subclasses may add more functions to this interface which are more specialized to the form of the layout. For example, QCPLayoutGrid adds functions that take row and column indices to access cells of the layout grid more conveniently.

Since this is an abstract base class, you can't instantiate it directly. Rather use one of its subclasses like QCPLayoutGrid or QCPLayoutInset.

For a general introduction to the layout system, see the dedicated documentation page The Layout System.

Definition at line 718 of file qcustomplot.h.

Constructor & Destructor Documentation

◆ QCPLayout()

QCPLayout::QCPLayout ( )
explicit

Creates an instance of QCPLayout and sets default values.

Note that since QCPLayout is an abstract base class, it can't be instantiated directly.

Definition at line 2255 of file qcustomplot.cpp.

Member Function Documentation

◆ adoptElement()

void QCPLayout::adoptElement ( QCPLayoutElement el)
protected

Definition at line 2414 of file qcustomplot.cpp.

◆ clear()

void QCPLayout::clear ( )

Removes and deletes all layout elements in this layout.

See also
remove, removeAt

Definition at line 2359 of file qcustomplot.cpp.

◆ elementAt()

QCPLayoutElement * QCPLayout::elementAt ( int  index) const
pure 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

Implemented in QCPLayoutGrid, and QCPLayoutInset.

◆ elementCount()

int QCPLayout::elementCount ( ) const
pure virtual

Returns the number of elements/cells in the layout.

See also
elements, elementAt

Implemented in QCPLayoutGrid, and QCPLayoutInset.

◆ elements()

QList< QCPLayoutElement * > QCPLayout::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 QCPLayoutElement.

Reimplemented in QCPLayoutGrid.

Definition at line 2285 of file qcustomplot.cpp.

◆ getSectionSizes()

QVector< int > QCPLayout::getSectionSizes ( QVector< int >  maxSizes,
QVector< int >  minSizes,
QVector< double >  stretchFactors,
int  totalSize 
) const
protected

Definition at line 2478 of file qcustomplot.cpp.

◆ releaseElement()

void QCPLayout::releaseElement ( QCPLayoutElement el)
protected

Definition at line 2437 of file qcustomplot.cpp.

◆ remove()

bool QCPLayout::remove ( QCPLayoutElement element)

Removes and deletes the provided element.

Returns true on success. If element is not in the layout, returns false.

This function internally uses takeAt to remove the element from the layout and then deletes the element.

See also
removeAt, take

Definition at line 2344 of file qcustomplot.cpp.

◆ removeAt()

bool QCPLayout::removeAt ( int  index)

Removes and deletes the element at the provided index.

Returns true on success. If index is invalid or points to an empty cell, returns false.

This function internally uses takeAt to remove the element from the layout and then deletes the returned element.

See also
remove, takeAt

Definition at line 2325 of file qcustomplot.cpp.

◆ simplify()

void QCPLayout::simplify ( )
virtual

Simplifies the layout by collapsing empty cells.

The exact behavior depends on subclasses, the default implementation does nothing.

Not all layouts need simplification. For example, QCPLayoutInset doesn't use explicit simplification while QCPLayoutGrid does.

Reimplemented in QCPLayoutGrid, and QCPLayoutInset.

Definition at line 2312 of file qcustomplot.cpp.

◆ sizeConstraintsChanged()

void QCPLayout::sizeConstraintsChanged ( ) const
protected

Subclasses call this method to report changed (minimum/maximum) size constraints.

If the parent of this layout is again a QCPLayout, forwards the call to the parent's sizeConstraintsChanged. If the parent is a QWidget (i.e. is the QCustomPlot::plotLayout of QCustomPlot), calls QWidget::updateGeometry, so if the QCustomPlot widget is inside a Qt QLayout, it may update itself and resize cells accordingly.

Definition at line 2377 of file qcustomplot.cpp.

◆ take()

bool QCPLayout::take ( QCPLayoutElement element)
pure 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

Implemented in QCPLayoutGrid, and QCPLayoutInset.

◆ takeAt()

QCPLayoutElement * QCPLayout::takeAt ( int  index)
pure 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

Implemented in QCPLayoutGrid, and QCPLayoutInset.

◆ update()

void QCPLayout::update ( UpdatePhase  phase)
virtual

First calls the QCPLayoutElement::update base class implementation to update the margins on this layout.

Then calls updateLayout which subclasses reimplement to reposition and resize their cells.

Finally, update is called on all child elements.

Reimplemented from QCPLayoutElement.

Definition at line 2267 of file qcustomplot.cpp.

◆ updateLayout()

void QCPLayout::updateLayout ( )
protectedvirtual

Reimplemented in QCPLayoutGrid, and QCPLayoutInset.

Definition at line 2397 of file qcustomplot.cpp.

Friends And Related Symbol Documentation

◆ QCPLayoutElement

friend class QCPLayoutElement
friend

Definition at line 752 of file qcustomplot.h.


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