CopperSpice API
1.9.2
|
The QGraphicsGridLayout class provides a grid layout for managing widgets in Graphics View. More...
Additional Inherited Members | |
Static Public Methods inherited from QGraphicsLayout | |
static bool | instantInvalidatePropagation () |
static void | setInstantInvalidatePropagation (bool enable) |
Protected Methods inherited from QGraphicsLayout | |
void | addChildLayoutItem (QGraphicsLayoutItem *layoutItem) |
Protected Methods inherited from QGraphicsLayoutItem | |
void | setGraphicsItem (QGraphicsItem *item) |
void | setOwnedByLayout (bool owner) |
The QGraphicsGridLayout class provides a grid layout for managing widgets in Graphics View.
The most common way to use QGraphicsGridLayout is to construct an object on the heap with no parent, add widgets and layouts by calling addItem(), and finally assign the layout to a widget by calling QGraphicsWidget::setLayout(). QGraphicsGridLayout automatically computes the dimensions of the grid as you add items.
The layout takes ownership of the items. In some cases when the layout item also inherits from QGraphicsItem (such as QGraphicsWidget) there will be an ambiguity in ownership because the layout item belongs to two ownership hierarchies. See the documentation of QGraphicsLayoutItem::setOwnedByLayout() how to handle this. You can access each item in the layout by calling count() and itemAt(). Calling removeAt() will remove an item from the layout, without destroying it.
QGraphicsGridLayout respects each item's size hints and size policies, and when a cell in the grid has more space than the items can fill, each item is arranged according to the layout's alignment for that item. You can set an alignment for each item by calling setAlignment(), and check the alignment for any item by calling alignment(). You can also set the alignment for an entire row or column by calling setRowAlignment() and setColumnAlignment() respectively. By default, items are aligned to the top left.
QGraphicsGridLayout::QGraphicsGridLayout | ( | QGraphicsLayoutItem * | parent = nullptr | ) |
Constructs a QGraphicsGridLayout instance. The parent object is passed to the QGraphicsLayout constructor.
|
virtual |
Destroys the QGraphicsGridLayout object.
void QGraphicsGridLayout::addItem | ( | QGraphicsLayoutItem * | item, |
int | row, | ||
int | column, | ||
int | rowSpan, | ||
int | columnSpan, | ||
Qt::Alignment | alignment = Qt::Alignment() |
||
) |
Adds item to the grid on row and column. You can specify a rowSpan and columnSpan and an optional alignment.
|
inline |
Adds item to the grid on row and column. You can specify an optional alignment for item.
Qt::Alignment QGraphicsGridLayout::alignment | ( | QGraphicsLayoutItem * | item | ) | const |
Returns the alignment for item.
Qt::Alignment QGraphicsGridLayout::columnAlignment | ( | int | column | ) | const |
Returns the alignment for column.
int QGraphicsGridLayout::columnCount | ( | ) | const |
Returns the number of columns in the grid layout. This is always one more than the index of the last column that is occupied by a layout item (empty columns are counted except for those at the end).
qreal QGraphicsGridLayout::columnMaximumWidth | ( | int | column | ) | const |
Returns the maximum width for column.
qreal QGraphicsGridLayout::columnMinimumWidth | ( | int | column | ) | const |
Returns the minimum width for column.
qreal QGraphicsGridLayout::columnPreferredWidth | ( | int | column | ) | const |
Returns the preferred width for column.
qreal QGraphicsGridLayout::columnSpacing | ( | int | column | ) | const |
Returns the column spacing for column.
int QGraphicsGridLayout::columnStretchFactor | ( | int | column | ) | const |
Returns the stretch factor for column.
|
overridevirtual |
Returns the number of layout items in this grid layout.
Implements QGraphicsLayout::count()
qreal QGraphicsGridLayout::horizontalSpacing | ( | ) | const |
Returns the default horizontal spacing for the grid layout.
|
overridevirtual |
Reimplemented from QGraphicsLayout::invalidate()
|
overridevirtual |
Returns the layout item at index or a nullptr if there is no layout item at this index.
Implements QGraphicsLayout::itemAt()
QGraphicsLayoutItem * QGraphicsGridLayout::itemAt | ( | int | row, |
int | column | ||
) | const |
Returns a pointer to the layout item at (row, column).
|
overridevirtual |
Removes the layout item at index without destroying it. Ownership of the item is transferred to the caller.
Implements QGraphicsLayout::removeAt()
void QGraphicsGridLayout::removeItem | ( | QGraphicsLayoutItem * | item | ) |
Removes the layout item without destroying it. Ownership of the item is transferred to the caller.
Qt::Alignment QGraphicsGridLayout::rowAlignment | ( | int | row | ) | const |
Returns the alignment of row.
int QGraphicsGridLayout::rowCount | ( | ) | const |
Returns the number of rows in the grid layout. This is always one more than the index of the last row that is occupied by a layout item (empty rows are counted except for those at the end).
qreal QGraphicsGridLayout::rowMaximumHeight | ( | int | row | ) | const |
Returns the maximum height for row, row.
qreal QGraphicsGridLayout::rowMinimumHeight | ( | int | row | ) | const |
Returns the minimum height for row, row.
qreal QGraphicsGridLayout::rowPreferredHeight | ( | int | row | ) | const |
Returns the preferred height for row, row.
qreal QGraphicsGridLayout::rowSpacing | ( | int | row | ) | const |
Returns the row spacing for row.
int QGraphicsGridLayout::rowStretchFactor | ( | int | row | ) | const |
Returns the stretch factor for row.
void QGraphicsGridLayout::setAlignment | ( | QGraphicsLayoutItem * | item, |
Qt::Alignment | alignment | ||
) |
Sets the alignment for item to alignment.
void QGraphicsGridLayout::setColumnAlignment | ( | int | column, |
Qt::Alignment | alignment | ||
) |
Sets the alignment for column to alignment.
void QGraphicsGridLayout::setColumnFixedWidth | ( | int | column, |
qreal | width | ||
) |
Sets the fixed width of column to width.
void QGraphicsGridLayout::setColumnMaximumWidth | ( | int | column, |
qreal | width | ||
) |
Sets the maximum width of column to width.
void QGraphicsGridLayout::setColumnMinimumWidth | ( | int | column, |
qreal | width | ||
) |
Sets the minimum width for column to width.
void QGraphicsGridLayout::setColumnPreferredWidth | ( | int | column, |
qreal | width | ||
) |
Sets the preferred width for column to width.
void QGraphicsGridLayout::setColumnSpacing | ( | int | column, |
qreal | spacing | ||
) |
Sets the spacing for column to spacing.
void QGraphicsGridLayout::setColumnStretchFactor | ( | int | column, |
int | stretch | ||
) |
Sets the stretch factor for column to stretch.
|
overridevirtual |
Sets the bounding geometry of the grid layout to rect.
Reimplemented from QGraphicsLayoutItem::setGeometry()
void QGraphicsGridLayout::setHorizontalSpacing | ( | qreal | spacing | ) |
Sets the default horizontal spacing for the grid layout to spacing.
void QGraphicsGridLayout::setRowAlignment | ( | int | row, |
Qt::Alignment | alignment | ||
) |
Sets the alignment of row to alignment.
void QGraphicsGridLayout::setRowFixedHeight | ( | int | row, |
qreal | height | ||
) |
Sets the fixed height for row, row, to height.
void QGraphicsGridLayout::setRowMaximumHeight | ( | int | row, |
qreal | height | ||
) |
Sets the maximum height for row, row, to height.
void QGraphicsGridLayout::setRowMinimumHeight | ( | int | row, |
qreal | height | ||
) |
Sets the minimum height for row, row, to height.
void QGraphicsGridLayout::setRowPreferredHeight | ( | int | row, |
qreal | height | ||
) |
Sets the preferred height for row, row, to height.
void QGraphicsGridLayout::setRowSpacing | ( | int | row, |
qreal | spacing | ||
) |
Sets the spacing for row to spacing.
void QGraphicsGridLayout::setRowStretchFactor | ( | int | row, |
int | stretch | ||
) |
Sets the stretch factor for row to stretch.
void QGraphicsGridLayout::setSpacing | ( | qreal | spacing | ) |
Sets the grid layout's default spacing, both vertical and horizontal, to spacing.
void QGraphicsGridLayout::setVerticalSpacing | ( | qreal | spacing | ) |
Sets the default vertical spacing for the grid layout to spacing.
|
overridevirtual |
Implements QGraphicsLayoutItem::sizeHint()
qreal QGraphicsGridLayout::verticalSpacing | ( | ) | const |
Returns the default vertical spacing for the grid layout.