QtBase
v6.3.1
|
The QGraphicsLayout class provides the base class for all layouts in Graphics View. More...
#include <qgraphicslayout.h>
Static Public Member Functions | |
static void | setInstantInvalidatePropagation (bool enable) |
static bool | instantInvalidatePropagation () |
Protected Member Functions | |
QGraphicsLayout (QGraphicsLayoutPrivate &, QGraphicsLayoutItem *) | |
void | addChildLayoutItem (QGraphicsLayoutItem *layoutItem) |
Protected Member Functions inherited from QGraphicsLayoutItem | |
void | setGraphicsItem (QGraphicsItem *item) |
void | setOwnedByLayout (bool ownedByLayout) |
QGraphicsLayoutItem (QGraphicsLayoutItemPrivate &dd) | |
virtual QSizeF | sizeHint (Qt::SizeHint which, const QSizeF &constraint=QSizeF()) const =0 |
Friends | |
class | QGraphicsWidget |
Additional Inherited Members | |
Protected Attributes inherited from QGraphicsLayoutItem | |
QScopedPointer< QGraphicsLayoutItemPrivate > | d_ptr |
The QGraphicsLayout class provides the base class for all layouts in Graphics View.
\inmodule QtWidgets
QGraphicsLayout is an abstract class that defines a virtual API for arranging QGraphicsWidget children and other QGraphicsLayoutItem objects for a QGraphicsWidget. QGraphicsWidget assigns responsibility to a QGraphicsLayout through QGraphicsWidget::setLayout(). As the widget is resized, the layout will automatically arrange the widget's children. QGraphicsLayout inherits QGraphicsLayoutItem, so, it can be managed by any layout, including its own subclasses.
Definition at line 54 of file qgraphicslayout.h.
QGraphicsLayout::QGraphicsLayout | ( | QGraphicsLayoutItem * | parent = nullptr | ) |
Constructs a QGraphicsLayout object.
parent is passed to QGraphicsLayoutItem's constructor and the QGraphicsLayoutItem's isLayout argument is set to true.
If parent is a QGraphicsWidget the layout will be installed on that widget. (Note that installing a layout will delete the old one installed.)
Definition at line 158 of file qgraphicslayout.cpp.
QGraphicsLayout::~QGraphicsLayout | ( | ) |
Destroys the QGraphicsLayout object.
Definition at line 200 of file qgraphicslayout.cpp.
|
protected |
void QGraphicsLayout::activate | ( | ) |
Activates the layout, causing all items in the layout to be immediately rearranged. This function is based on calling count() and itemAt(), and then calling setGeometry() on all items sequentially. When activated, the layout will adjust its geometry to its parent's contentsRect(). The parent will then invalidate any layout of its own.
If called in sequence or recursively, e.g., by one of the arranged items in response to being resized, this function will do nothing.
Note that the layout is free to use geometry caching to optimize this process. To forcefully invalidate any such cache, you can call invalidate() before calling activate().
Definition at line 257 of file qgraphicslayout.cpp.
|
protected |
This function is a convenience function provided for custom layouts, and will go through all items in the layout and reparent their graphics items to the closest QGraphicsWidget ancestor of the layout.
If layoutItem is already in a different layout, it will be removed from that layout.
If custom layouts want special behaviour they can ignore to use this function, and implement their own behaviour.
Definition at line 472 of file qgraphicslayout.cpp.
|
pure virtual |
This pure virtual function must be reimplemented in a subclass of QGraphicsLayout to return the number of items in the layout.
The subclass is free to decide how to store the items.
Implemented in CustomLayout, Layout, QGraphicsLinearLayout, QGraphicsGridLayout, QGraphicsAnchorLayout, FlowLayout, and FlowLayout.
|
overridevirtual |
\reimp
Reimplemented from QGraphicsLayoutItem.
Definition at line 232 of file qgraphicslayout.cpp.
|
static |
|
virtual |
Clears any cached geometry and size hint information in the layout, and posts a \l{QEvent::LayoutRequest}{LayoutRequest} event to the managed parent QGraphicsLayoutItem.
Reimplemented in TestLayout, TestLayout, QGraphicsLinearLayout, QGraphicsGridLayout, and QGraphicsAnchorLayout.
Definition at line 311 of file qgraphicslayout.cpp.
bool QGraphicsLayout::isActivated | ( | ) | const |
Returns true
if the layout is currently being activated; otherwise, returns false
. If the layout is being activated, this means that it is currently in the process of rearranging its items (i.e., the activate() function has been called, and has not yet returned).
Definition at line 298 of file qgraphicslayout.cpp.
|
pure virtual |
This pure virtual function must be reimplemented in a subclass of QGraphicsLayout to return a pointer to the item at index i. The reimplementation can assume that i is valid (i.e., it respects the value of count()). Together with count(), it is provided as a means of iterating over all items in a layout.
The subclass is free to decide how to store the items, and the visual arrangement does not have to be reflected through this function.
Implemented in CustomLayout, Layout, QGraphicsLinearLayout, QGraphicsGridLayout, QGraphicsAnchorLayout, FlowLayout, and FlowLayout.
|
pure virtual |
This pure virtual function must be reimplemented in a subclass of QGraphicsLayout to remove the item at index. The reimplementation can assume that index is valid (i.e., it respects the value of count()).
The implementation must ensure that the parentLayoutItem() of the removed item does not point to this layout, since the item is considered to be removed from the layout hierarchy.
If the layout is to be reused between applications, we recommend that the layout deletes the item, but the graphics view framework does not depend on this.
The subclass is free to decide how to store the items.
Implemented in CustomLayout, Layout, QGraphicsLinearLayout, QGraphicsGridLayout, QGraphicsAnchorLayout, and FlowLayout.
Sets the contents margins to left, top, right and bottom. The default contents margins for toplevel layouts are style dependent (by querying the pixelMetric for QStyle::PM_LayoutLeftMargin, QStyle::PM_LayoutTopMargin, QStyle::PM_LayoutRightMargin and QStyle::PM_LayoutBottomMargin).
For sublayouts the default margins are 0.
Changing the contents margins automatically invalidates the layout.
Definition at line 217 of file qgraphicslayout.cpp.
|
static |
|
overridevirtual |
\reimp
Reimplemented from QGraphicsLayoutItem.
Definition at line 350 of file qgraphicslayout.cpp.
This virtual event handler receives all events for the managed widget. QGraphicsLayout uses this event handler to listen for layout related events such as geometry changes, layout changes or layout direction changes.
e is a pointer to the event.
You can reimplement this event handler to track similar events for your own custom layout.
Reimplemented in SubQGraphicsLinearLayout.
Definition at line 390 of file qgraphicslayout.cpp.
|
friend |
Definition at line 83 of file qgraphicslayout.h.