[][src]Struct qt_widgets::QGraphicsAnchorLayout

#[repr(C)]pub struct QGraphicsAnchorLayout { /* fields omitted */ }

The QGraphicsAnchorLayout class provides a layout where one can anchor widgets together in Graphics View.

C++ class: QGraphicsAnchorLayout.

C++ documentation:

The QGraphicsAnchorLayout class provides a layout where one can anchor widgets together in Graphics View.

The anchor layout allows developers to specify how widgets should be placed relative to each other, and to the layout itself. The specification is made by adding anchors to the layout by calling addAnchor(), addAnchors() or addCornerAnchors().

Existing anchors in the layout can be accessed with the anchor() function. Items that are anchored are automatically added to the layout, and if items are removed, all their anchors will be automatically removed.

Using an anchor layout to align simple colored widgets.

Anchors are always set up between edges of an item, where the "center" is also considered to be an edge. Consider the following example:

layout->addAnchor(b, Qt::AnchorLeft, a, Qt::AnchorRight); layout->addAnchor(b, Qt::AnchorTop, a, Qt::AnchorBottom);

Here, the right edge of item a is anchored to the left edge of item b and the bottom edge of item a is anchored to the top edge of item b, with the result that item b will be placed diagonally to the right and below item b.

The addCornerAnchors() function provides a simpler way of anchoring the corners of two widgets than the two individual calls to addAnchor() shown in the code above. Here, we see how a widget can be anchored to the top-left corner of the enclosing layout:

layout->addCornerAnchors(a, Qt::TopLeftCorner, layout, Qt::TopLeftCorner);

In cases where anchors are used to match the widths or heights of widgets, it is convenient to use the addAnchors() function. As with the other functions for specifying anchors, it can also be used to anchor a widget to a layout.

Methods

impl QGraphicsAnchorLayout[src]

pub unsafe fn add_anchor(
    &self,
    first_item: impl CastInto<Ptr<QGraphicsLayoutItem>>,
    first_edge: AnchorPoint,
    second_item: impl CastInto<Ptr<QGraphicsLayoutItem>>,
    second_edge: AnchorPoint
) -> QPtr<QGraphicsAnchor>
[src]

Creates an anchor between the edge firstEdge of item firstItem and the edge secondEdge of item secondItem. The spacing of the anchor is picked up from the style. Anchors between a layout edge and an item edge will have a size of 0. If there is already an anchor between the edges, the new anchor will replace the old one.

Calls C++ function: QGraphicsAnchor* QGraphicsAnchorLayout::addAnchor(QGraphicsLayoutItem* firstItem, Qt::AnchorPoint firstEdge, QGraphicsLayoutItem* secondItem, Qt::AnchorPoint secondEdge).

C++ documentation:

Creates an anchor between the edge firstEdge of item firstItem and the edge secondEdge of item secondItem. The spacing of the anchor is picked up from the style. Anchors between a layout edge and an item edge will have a size of 0. If there is already an anchor between the edges, the new anchor will replace the old one.

firstItem and secondItem are automatically added to the layout if they are not part of the layout. This means that count() can increase by up to 2.

The spacing an anchor will get depends on the type of anchor. For instance, anchors from the Right edge of one item to the Left edge of another (or vice versa) will use the default horizontal spacing. The same behaviour applies to Bottom to Top anchors, (but they will use the default vertical spacing). For all other anchor combinations, the spacing will be 0. All anchoring functions will follow this rule.

The spacing can also be set manually by using QGraphicsAnchor::setSpacing() method.

Calling this function where firstItem or secondItem are ancestors of the layout have undefined behaviour.

See also addAnchors() and addCornerAnchors().

pub unsafe fn add_anchors_3a(
    &self,
    first_item: impl CastInto<Ptr<QGraphicsLayoutItem>>,
    second_item: impl CastInto<Ptr<QGraphicsLayoutItem>>,
    orientations: QFlags<Orientation>
)
[src]

Anchors two or four edges of firstItem with the corresponding edges of secondItem, so that firstItem has the same size as secondItem in the dimensions specified by orientations.

Calls C++ function: void QGraphicsAnchorLayout::addAnchors(QGraphicsLayoutItem* firstItem, QGraphicsLayoutItem* secondItem, QFlags<Qt::Orientation> orientations = …).

C++ documentation:

Anchors two or four edges of firstItem with the corresponding edges of secondItem, so that firstItem has the same size as secondItem in the dimensions specified by orientations.

For example, the following example anchors the left and right edges of two items to match their widths:

layout->addAnchor(b, Qt::AnchorLeft, c, Qt::AnchorLeft); layout->addAnchor(b, Qt::AnchorRight, c, Qt::AnchorRight);

This can also be achieved using the following line of code:

layout->addAnchors(b, c, Qt::Horizontal);

See also addAnchor() and addCornerAnchors().

pub unsafe fn add_anchors_2a(
    &self,
    first_item: impl CastInto<Ptr<QGraphicsLayoutItem>>,
    second_item: impl CastInto<Ptr<QGraphicsLayoutItem>>
)
[src]

Anchors two or four edges of firstItem with the corresponding edges of secondItem, so that firstItem has the same size as secondItem in the dimensions specified by orientations.

Calls C++ function: void QGraphicsAnchorLayout::addAnchors(QGraphicsLayoutItem* firstItem, QGraphicsLayoutItem* secondItem).

C++ documentation:

Anchors two or four edges of firstItem with the corresponding edges of secondItem, so that firstItem has the same size as secondItem in the dimensions specified by orientations.

For example, the following example anchors the left and right edges of two items to match their widths:

layout->addAnchor(b, Qt::AnchorLeft, c, Qt::AnchorLeft); layout->addAnchor(b, Qt::AnchorRight, c, Qt::AnchorRight);

This can also be achieved using the following line of code:

layout->addAnchors(b, c, Qt::Horizontal);

See also addAnchor() and addCornerAnchors().

pub unsafe fn add_corner_anchors(
    &self,
    first_item: impl CastInto<Ptr<QGraphicsLayoutItem>>,
    first_corner: Corner,
    second_item: impl CastInto<Ptr<QGraphicsLayoutItem>>,
    second_corner: Corner
)
[src]

Creates two anchors between firstItem and secondItem specified by the corners, firstCorner and secondCorner, where one is for the horizontal edge and another one for the vertical edge.

Calls C++ function: void QGraphicsAnchorLayout::addCornerAnchors(QGraphicsLayoutItem* firstItem, Qt::Corner firstCorner, QGraphicsLayoutItem* secondItem, Qt::Corner secondCorner).

C++ documentation:

Creates two anchors between firstItem and secondItem specified by the corners, firstCorner and secondCorner, where one is for the horizontal edge and another one for the vertical edge.

This is a convenience function, since anchoring corners can be expressed as anchoring two edges. For instance:

layout->addAnchor(a, Qt::AnchorTop, layout, Qt::AnchorTop); layout->addAnchor(a, Qt::AnchorLeft, layout, Qt::AnchorLeft);

This can also be achieved with the following line of code:

layout->addCornerAnchors(a, Qt::TopLeftCorner, layout, Qt::TopLeftCorner);

If there is already an anchor between the edge pairs, it will be replaced by the anchors that this function specifies.

firstItem and secondItem are automatically added to the layout if they are not part of the layout. This means that count() can increase by up to 2.

See also addAnchor() and addAnchors().

pub unsafe fn anchor(
    &self,
    first_item: impl CastInto<Ptr<QGraphicsLayoutItem>>,
    first_edge: AnchorPoint,
    second_item: impl CastInto<Ptr<QGraphicsLayoutItem>>,
    second_edge: AnchorPoint
) -> QPtr<QGraphicsAnchor>
[src]

Returns the anchor between the anchor points defined by firstItem and firstEdge and secondItem and secondEdge. If there is no such anchor, the function will return 0.

Calls C++ function: QGraphicsAnchor* QGraphicsAnchorLayout::anchor(QGraphicsLayoutItem* firstItem, Qt::AnchorPoint firstEdge, QGraphicsLayoutItem* secondItem, Qt::AnchorPoint secondEdge).

C++ documentation:

Returns the anchor between the anchor points defined by firstItem and firstEdge and secondItem and secondEdge. If there is no such anchor, the function will return 0.

pub unsafe fn count(&self) -> c_int[src]

Reimplemented from QGraphicsLayout::count().

Calls C++ function: virtual int QGraphicsAnchorLayout::count() const.

C++ documentation:

Reimplemented from QGraphicsLayout::count().

pub unsafe fn horizontal_spacing(&self) -> c_double[src]

Returns the default horizontal spacing for the anchor layout.

Calls C++ function: double QGraphicsAnchorLayout::horizontalSpacing() const.

C++ documentation:

Returns the default horizontal spacing for the anchor layout.

See also verticalSpacing() and setHorizontalSpacing().

pub unsafe fn invalidate(&self)[src]

Reimplemented from QGraphicsLayout::invalidate().

Calls C++ function: virtual void QGraphicsAnchorLayout::invalidate().

C++ documentation:

Reimplemented from QGraphicsLayout::invalidate().

pub unsafe fn item_at(&self, index: c_int) -> Ptr<QGraphicsLayoutItem>[src]

Reimplemented from QGraphicsLayout::itemAt().

Calls C++ function: virtual QGraphicsLayoutItem* QGraphicsAnchorLayout::itemAt(int index) const.

C++ documentation:

Reimplemented from QGraphicsLayout::itemAt().

pub unsafe fn new_1a(
    parent: impl CastInto<Ptr<QGraphicsLayoutItem>>
) -> CppBox<QGraphicsAnchorLayout>
[src]

Constructs a QGraphicsAnchorLayout instance. parent is passed to QGraphicsLayout's constructor.

Calls C++ function: [constructor] void QGraphicsAnchorLayout::QGraphicsAnchorLayout(QGraphicsLayoutItem* parent = …).

C++ documentation:

Constructs a QGraphicsAnchorLayout instance. parent is passed to QGraphicsLayout's constructor.

pub unsafe fn new_0a() -> CppBox<QGraphicsAnchorLayout>[src]

The QGraphicsAnchorLayout class provides a layout where one can anchor widgets together in Graphics View.

Calls C++ function: [constructor] void QGraphicsAnchorLayout::QGraphicsAnchorLayout().

C++ documentation:

The QGraphicsAnchorLayout class provides a layout where one can anchor widgets together in Graphics View.

The anchor layout allows developers to specify how widgets should be placed relative to each other, and to the layout itself. The specification is made by adding anchors to the layout by calling addAnchor(), addAnchors() or addCornerAnchors().

Existing anchors in the layout can be accessed with the anchor() function. Items that are anchored are automatically added to the layout, and if items are removed, all their anchors will be automatically removed.

Using an anchor layout to align simple colored widgets.

Anchors are always set up between edges of an item, where the "center" is also considered to be an edge. Consider the following example:

layout->addAnchor(b, Qt::AnchorLeft, a, Qt::AnchorRight); layout->addAnchor(b, Qt::AnchorTop, a, Qt::AnchorBottom);

Here, the right edge of item a is anchored to the left edge of item b and the bottom edge of item a is anchored to the top edge of item b, with the result that item b will be placed diagonally to the right and below item b.

The addCornerAnchors() function provides a simpler way of anchoring the corners of two widgets than the two individual calls to addAnchor() shown in the code above. Here, we see how a widget can be anchored to the top-left corner of the enclosing layout:

layout->addCornerAnchors(a, Qt::TopLeftCorner, layout, Qt::TopLeftCorner);

In cases where anchors are used to match the widths or heights of widgets, it is convenient to use the addAnchors() function. As with the other functions for specifying anchors, it can also be used to anchor a widget to a layout.

pub unsafe fn remove_at(&self, index: c_int)[src]

Reimplemented from QGraphicsLayout::removeAt().

Calls C++ function: virtual void QGraphicsAnchorLayout::removeAt(int index).

C++ documentation:

Reimplemented from QGraphicsLayout::removeAt().

Removes the layout item at index without destroying it. Ownership of the item is transferred to the caller.

Removing an item will also remove any of the anchors associated with it.

See also itemAt() and count().

pub unsafe fn set_geometry(&self, rect: impl CastInto<Ref<QRectF>>)[src]

Reimplemented from QGraphicsLayoutItem::setGeometry().

Calls C++ function: virtual void QGraphicsAnchorLayout::setGeometry(const QRectF& rect).

C++ documentation:

Reimplemented from QGraphicsLayoutItem::setGeometry().

pub unsafe fn set_horizontal_spacing(&self, spacing: c_double)[src]

Sets the default horizontal spacing for the anchor layout to spacing.

Calls C++ function: void QGraphicsAnchorLayout::setHorizontalSpacing(double spacing).

C++ documentation:

Sets the default horizontal spacing for the anchor layout to spacing.

See also horizontalSpacing(), setVerticalSpacing(), and setSpacing().

pub unsafe fn set_spacing(&self, spacing: c_double)[src]

Sets the default horizontal and the default vertical spacing for the anchor layout to spacing.

Calls C++ function: void QGraphicsAnchorLayout::setSpacing(double spacing).

C++ documentation:

Sets the default horizontal and the default vertical spacing for the anchor layout to spacing.

If an item is anchored with no spacing associated with the anchor, it will use the default spacing.

QGraphicsAnchorLayout does not support negative spacings. Setting a negative value will unset the previous spacing and make the layout use the spacing provided by the current widget style.

See also setHorizontalSpacing() and setVerticalSpacing().

pub unsafe fn set_vertical_spacing(&self, spacing: c_double)[src]

Sets the default vertical spacing for the anchor layout to spacing.

Calls C++ function: void QGraphicsAnchorLayout::setVerticalSpacing(double spacing).

C++ documentation:

Sets the default vertical spacing for the anchor layout to spacing.

See also verticalSpacing(), setHorizontalSpacing(), and setSpacing().

pub unsafe fn vertical_spacing(&self) -> c_double[src]

Returns the default vertical spacing for the anchor layout.

Calls C++ function: double QGraphicsAnchorLayout::verticalSpacing() const.

C++ documentation:

Returns the default vertical spacing for the anchor layout.

See also horizontalSpacing() and setVerticalSpacing().

Methods from Deref<Target = QGraphicsLayout>

pub unsafe fn activate(&self)[src]

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.

Calls C++ function: void QGraphicsLayout::activate().

C++ documentation:

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

See also invalidate().

pub unsafe fn count(&self) -> c_int[src]

This pure virtual function must be reimplemented in a subclass of QGraphicsLayout to return the number of items in the layout.

Calls C++ function: pure virtual int QGraphicsLayout::count() const.

C++ documentation:

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.

See also itemAt() and removeAt().

pub unsafe fn get_contents_margins(
    &self,
    left: *mut c_double,
    top: *mut c_double,
    right: *mut c_double,
    bottom: *mut c_double
)
[src]

Reimplemented from QGraphicsLayoutItem::getContentsMargins().

Calls C++ function: virtual void QGraphicsLayout::getContentsMargins(double* left, double* top, double* right, double* bottom) const.

C++ documentation:

Reimplemented from QGraphicsLayoutItem::getContentsMargins().

pub unsafe fn invalidate(&self)[src]

Clears any cached geometry and size hint information in the layout, and posts a LayoutRequest event to the managed parent QGraphicsLayoutItem.

Calls C++ function: virtual void QGraphicsLayout::invalidate().

C++ documentation:

Clears any cached geometry and size hint information in the layout, and posts a LayoutRequest event to the managed parent QGraphicsLayoutItem.

See also activate() and setGeometry().

pub unsafe fn is_activated(&self) -> bool[src]

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

Calls C++ function: bool QGraphicsLayout::isActivated() const.

C++ documentation:

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

See also activate() and invalidate().

pub unsafe fn item_at(&self, i: c_int) -> Ptr<QGraphicsLayoutItem>[src]

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.

Calls C++ function: pure virtual QGraphicsLayoutItem* QGraphicsLayout::itemAt(int i) const.

C++ documentation:

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.

See also count() and removeAt().

pub unsafe fn remove_at(&self, index: c_int)[src]

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

Calls C++ function: pure virtual void QGraphicsLayout::removeAt(int index).

C++ documentation:

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.

See also itemAt() and count().

pub unsafe fn set_contents_margins(
    &self,
    left: c_double,
    top: c_double,
    right: c_double,
    bottom: c_double
)
[src]

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

Calls C++ function: void QGraphicsLayout::setContentsMargins(double left, double top, double right, double bottom).

C++ documentation:

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.

See also invalidate().

pub unsafe fn update_geometry(&self)[src]

Reimplemented from QGraphicsLayoutItem::updateGeometry().

Calls C++ function: virtual void QGraphicsLayout::updateGeometry().

C++ documentation:

Reimplemented from QGraphicsLayoutItem::updateGeometry().

pub unsafe fn widget_event(&self, e: impl CastInto<Ptr<QEvent>>)[src]

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.

Calls C++ function: virtual void QGraphicsLayout::widgetEvent(QEvent* e).

C++ documentation:

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.

See also QGraphicsWidget::event() and QGraphicsItem::sceneEvent().

Trait Implementations

impl CppDeletable for QGraphicsAnchorLayout[src]

unsafe fn delete(&self)[src]

Destroys the QGraphicsAnchorLayout object.

Calls C++ function: virtual [destructor] void QGraphicsAnchorLayout::~QGraphicsAnchorLayout().

C++ documentation:

Destroys the QGraphicsAnchorLayout object.

impl Deref for QGraphicsAnchorLayout[src]

type Target = QGraphicsLayout

The resulting type after dereferencing.

fn deref(&self) -> &QGraphicsLayout[src]

Calls C++ function: QGraphicsLayout* static_cast<QGraphicsLayout*>(QGraphicsAnchorLayout* ptr).

impl DynamicCast<QGraphicsAnchorLayout> for QGraphicsLayout[src]

unsafe fn dynamic_cast(ptr: Ptr<QGraphicsLayout>) -> Ptr<QGraphicsAnchorLayout>[src]

Calls C++ function: QGraphicsAnchorLayout* dynamic_cast<QGraphicsAnchorLayout*>(QGraphicsLayout* ptr).

impl DynamicCast<QGraphicsAnchorLayout> for QGraphicsLayoutItem[src]

unsafe fn dynamic_cast(
    ptr: Ptr<QGraphicsLayoutItem>
) -> Ptr<QGraphicsAnchorLayout>
[src]

Calls C++ function: QGraphicsAnchorLayout* dynamic_cast<QGraphicsAnchorLayout*>(QGraphicsLayoutItem* ptr).

impl StaticDowncast<QGraphicsAnchorLayout> for QGraphicsLayout[src]

unsafe fn static_downcast(
    ptr: Ptr<QGraphicsLayout>
) -> Ptr<QGraphicsAnchorLayout>
[src]

Calls C++ function: QGraphicsAnchorLayout* static_cast<QGraphicsAnchorLayout*>(QGraphicsLayout* ptr).

impl StaticDowncast<QGraphicsAnchorLayout> for QGraphicsLayoutItem[src]

unsafe fn static_downcast(
    ptr: Ptr<QGraphicsLayoutItem>
) -> Ptr<QGraphicsAnchorLayout>
[src]

Calls C++ function: QGraphicsAnchorLayout* static_cast<QGraphicsAnchorLayout*>(QGraphicsLayoutItem* ptr).

impl StaticUpcast<QGraphicsLayout> for QGraphicsAnchorLayout[src]

unsafe fn static_upcast(ptr: Ptr<QGraphicsAnchorLayout>) -> Ptr<QGraphicsLayout>[src]

Calls C++ function: QGraphicsLayout* static_cast<QGraphicsLayout*>(QGraphicsAnchorLayout* ptr).

impl StaticUpcast<QGraphicsLayoutItem> for QGraphicsAnchorLayout[src]

unsafe fn static_upcast(
    ptr: Ptr<QGraphicsAnchorLayout>
) -> Ptr<QGraphicsLayoutItem>
[src]

Calls C++ function: QGraphicsLayoutItem* static_cast<QGraphicsLayoutItem*>(QGraphicsAnchorLayout* ptr).

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T, U> CastInto<U> for T where
    U: CastFrom<T>, 
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> StaticUpcast<T> for T[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.