Layout stringing items in rows and columns. More…
#include <QskLinearBox.h>
Inherits from QskIndexedLayoutBox, QskBox
Name | |
---|---|
void | transpose() Invert the orientation of the layout. |
void | activate() |
void | invalidate() |
void | clear(bool autoDelete =false) |
Name | |
---|---|
void | orientationChanged() |
void | dimensionChanged() |
void | defaultAlignmentChanged() |
void | spacingChanged() |
void | extraSpacingAtChanged() |
Name | |
---|---|
QskLinearBox(QQuickItem * parent =nullptr) Create a row layout. |
|
QskLinearBox(Qt::Orientation orientation, QQuickItem * parent =nullptr) Create a row or column layout. |
|
QskLinearBox(Qt::Orientation orientation, uint dimension, QQuickItem * parent =nullptr) Constructor. |
|
~QskLinearBox() override | |
bool | isEmpty() const |
int | elementCount() const |
qreal | spacingAtIndex(int index) const |
QQuickItem * | itemAtIndex(int index) const |
int | indexOf(const QQuickItem * item) const |
void | removeItem(const QQuickItem * item) |
void | removeAt(int index) |
Qt::Orientation | orientation() const |
void | setOrientation(Qt::Orientation orientation) Set the orientation of the layout. |
void | setDimension(uint dimension) Set the dimension of the layout. |
uint | dimension() const |
void | setExtraSpacingAt(Qt::Edges edges) |
Qt::Edges | extraSpacingAt() const |
void | setDefaultAlignment(Qt::Alignment alignment) |
Qt::Alignment | defaultAlignment() const |
void | setSpacing(qreal spacing) Set the global spacing of the layout. |
void | resetSpacing() Reset the global spacing to its initial value. |
qreal | spacing() const |
Q_INVOKABLE int | addItem(QQuickItem * item) |
int | addItem(QQuickItem * item, Qt::Alignment alignment) |
Q_INVOKABLE int | insertItem(int index, QQuickItem * item) |
int | insertItem(int index, QQuickItem * item, Qt::Alignment alignment) |
Q_INVOKABLE int | addSpacer(qreal spacing, int stretchFactor =0) Append a spacer to the layout. |
Q_INVOKABLE int | insertSpacer(int index, qreal spacing, int stretchFactor =0) Insert a spacer at a specific position. |
Q_INVOKABLE int | addStretch(int stretchFactor =0) Append a stretch to the layout. |
Q_INVOKABLE int | insertStretch(int index, int stretchFactor =0) Insert a stretch at a specific position. |
Q_INVOKABLE void | setStretchFactor(int index, int stretchFactor) Modify the stretch factor of a layout element. |
Q_INVOKABLE int | stretchFactor(int index) const |
void | setStretchFactor(const QQuickItem * item, int stretchFactor) Modify the stretch factor of an inserted item. |
int | stretchFactor(const QQuickItem * item) const |
void | dump() const |
Name | |
---|---|
bool | event(QEvent * event) override |
virtual void | geometryChangeEvent(QskGeometryChangeEvent * ) override |
void | itemChange(ItemChange change, const ItemChangeData & value) override |
virtual void | updateLayout() override |
virtual QSizeF | layoutSizeHint(Qt::SizeHint which, const QSizeF & constraint) const override |
Name | |
---|---|
Qt::Orientation | orientation Direction of flow for laying out the items. |
uint | dimension Upper limit for the number of elements in a row or column. |
qreal | spacing Global layout spacing. |
Qt::Alignment | defaultAlignment |
Qt::Edges | extraSpacingAt |
int | elementCount |
bool | empty |
Public Signals inherited from QskIndexedLayoutBox
Name | |
---|---|
void | autoAddChildrenChanged() |
Public Functions inherited from QskIndexedLayoutBox
Name | |
---|---|
QskIndexedLayoutBox(QQuickItem * parent =nullptr) Constructor. |
|
~QskIndexedLayoutBox() override Destructor. |
|
void | setAutoAddChildren(bool on =true) En/Disable auto appending of children. |
bool | autoAddChildren() const |
Protected Functions inherited from QskIndexedLayoutBox
Name | |
---|---|
void | reparentItem(QQuickItem * item) |
void | unparentItem(QQuickItem * item) |
Public Properties inherited from QskIndexedLayoutBox
Name | |
---|---|
bool | autoAddChildren Flag controlling whether to automatically append children to the layout. |
class QskLinearBox;
Layout stringing items in rows and columns.
See: QskGridBox, QskStackBox
Note: All available Qsk layouts are thin layers on top of the same grid based workhorse ( = QGridLayoutEngine ). QskLinearBox offers a reasonable subset of features, tailored for an index based point of view.
QskLinearBox organizes layout items in vertical or horizontal order ( orientation ). When the number of items for a row/column has reached an upper limit ( dimension ) the following items will be added to a new row/column.
When having the dimension being set to unlimited ( or 1 with the inverted orientation ) the string layout behaves similar to QBoxLayout, RowLayout/ColumnLayout ( QML ) or what is sometimes called a linear layout.
When not restricting the layout to one row/column only the layout can be used to set up simple grid formations.
Layout items may be QQuickItem *s or spacers - both having a stretch factor in the range of [0..10];
void transpose()
Invert the orientation of the layout.
See: setOrientation(), orientation(), orientationChanged()
Qt::Horizontal becomes to Qt::Vertical and v.v.
void activate()
void invalidate()
void clear(
bool autoDelete =false
)
void orientationChanged()
See: orientation
The orientation of the layout has changed
void dimensionChanged()
See: setDimension(), dimension()
The dimension of the layout has changed
void defaultAlignmentChanged()
void spacingChanged()
See: setSpacing(), spacing(), setRowSpacing(), setColumnSpacing()
The spacing of the layout has changed
void extraSpacingAtChanged()
explicit QskLinearBox(
QQuickItem * parent =nullptr
)
Create a row layout.
Parameters:
See: orientation, dimension
The orientation is set to Qt::Horizontal orientation having an unlimited dimension.
explicit QskLinearBox(
Qt::Orientation orientation,
QQuickItem * parent =nullptr
)
Create a row or column layout.
Parameters:
See: orientation, dimension
The dimension is unlimited.
QskLinearBox(
Qt::Orientation orientation,
uint dimension,
QQuickItem * parent =nullptr
)
Constructor.
Parameters:
See: orientation, dimension
~QskLinearBox() override
Destructor
inline bool isEmpty() const
int elementCount() const
qreal spacingAtIndex(
int index
) const
QQuickItem * itemAtIndex(
int index
) const
int indexOf(
const QQuickItem * item
) const
void removeItem(
const QQuickItem * item
)
void removeAt(
int index
)
Qt::Orientation orientation() const
Return: Value of the orientation property
void setOrientation(
Qt::Orientation orientation
)
Set the orientation of the layout.
Parameters:
See: orientation
void setDimension(
uint dimension
)
Set the dimension of the layout.
Parameters:
See: dimension
Warning: A value of 0 is invalid and will be set to 1
uint dimension() const
void setExtraSpacingAt(
Qt::Edges edges
)
Qt::Edges extraSpacingAt() const
void setDefaultAlignment(
Qt::Alignment alignment
)
Qt::Alignment defaultAlignment() const
void setSpacing(
qreal spacing
)
Set the global spacing of the layout.
Parameters:
See: spacing
void resetSpacing()
Reset the global spacing to its initial value.
See: spacing
qreal spacing() const
Q_INVOKABLE int addItem(
QQuickItem * item
)
int addItem(
QQuickItem * item,
Qt::Alignment alignment
)
Q_INVOKABLE int insertItem(
int index,
QQuickItem * item
)
int insertItem(
int index,
QQuickItem * item,
Qt::Alignment alignment
)
Q_INVOKABLE int addSpacer(
qreal spacing,
int stretchFactor =0
)
Append a spacer to the layout.
Parameters:
See: insertSpacer()
The same as insertSpacer( -1, spacing, stretchFactor );
Q_INVOKABLE int insertSpacer(
int index,
qreal spacing,
int stretchFactor =0
)
Insert a spacer at a specific position.
Parameters:
See: insertItem(), QskLayout::itemAtIndex()
Note: Calling QskLayout::itemAtIndex( index ) will return a nullptr.
Spacers being inserted to the layout are elements having an index - like regular QQuickItem *s and participate in the calculation of the geometries.
A spacer is treated like being an item with a preferred width/height of spacing. In case of having a stretchFactor > 0 the width/height might exceed spacing.
Q_INVOKABLE int addStretch(
int stretchFactor =0
)
Append a stretch to the layout.
Parameters:
See: insertStretch(), addSpacer()
The same as insertStretch( -1, stretchFactor );
Q_INVOKABLE int insertStretch(
int index,
int stretchFactor =0
)
Insert a stretch at a specific position.
Parameters:
See: insertSpacer(), QskLayout::itemAtIndex()
Note: Calling QskLayout::itemAtIndex( index ) will return a nullptr.
A stretch is simply a spacer with a spacing of 0
Q_INVOKABLE void setStretchFactor(
int index,
int stretchFactor
)
Modify the stretch factor of a layout element.
Parameters:
See: stretchFactor()
Q_INVOKABLE int stretchFactor(
int index
) const
Parameters:
See: setStretchFactor()
Return: Stretch factor of a layout element
void setStretchFactor(
const QQuickItem * item,
int stretchFactor
)
Modify the stretch factor of an inserted item.
Parameters:
See: stretchFactor()
int stretchFactor(
const QQuickItem * item
) const
Parameters:
See: setStretchFactor()
Return: Stretch factor of a layout element
void dump() const
bool event(
QEvent * event
) override
virtual void geometryChangeEvent(
QskGeometryChangeEvent *
) override
Parameters:
See: geometryChange() \saqt QObject::installEventFilter()
Reimplements: QskQuickItem::geometryChangeEvent
For no known reason QQuickItem propagates changes of position and size by calling QQuickItem::geometryChange(), instead of using events.
QskQuickItem reestablished the more powerful concept of events by sending/posting events, that can be preprocessed by event filtering.
void itemChange(
ItemChange change,
const ItemChangeData & value
) override
virtual void updateLayout() override
Reimplements: QskControl::updateLayout
virtual QSizeF layoutSizeHint(
Qt::SizeHint which,
const QSizeF & constraint
) const override
Reimplements: QskControl::layoutSizeHint
Qt::Orientation orientation;
Direction of flow for laying out the items.
See: transpose(), dimension
Par: Access functions:
orientation(), setOrientation(), orientationChanged()
In case of Qt::Horizontal the elements are organized horizontally increasing the column index, when appending an item. When the number of columns exceeds the dimension the next item will be in the first column of the next row ( v.v for Qt::Vertical ).
The horizontal layout direction is affected by its state of QskControl::layoutMirroring(), what might depend on the QskControl::locale().
uint dimension;
Upper limit for the number of elements in a row or column.
See: orientation
Return: Value of the dimension property const
Par: Access functions:
dimension(), setDimension(), dimensionChanged()
According to the orientation the layout is organized in rows or columns. The dimension is an upper limit for the number of elements in a row/column.
When the number of elements exceeds the dimension the following element will be inserted in the following row/column.
qreal spacing;
Global layout spacing.
See: setRowSpacing(), setColumnSpacing(), insertSpacer(), QskControl::setMargins()
Return: Value of the spacing property
Note: In opposite to a spacer, the global spacing does not insert elements.
Par: Access functions:
spacing(), setSpacing(), spacingChanged()
The spacing is the distance between each cell and row of the layout. Its initial value depend on the current theme.
Beside setting the global spacing it is also possible to add individual spacings at the end of each row and column.
Qt::Alignment defaultAlignment;
Qt::Edges extraSpacingAt;
int elementCount;
bool empty;
Updated on 28 July 2023 at 14:02:28 CEST