Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
Loading...
Searching...
No Matches
QGraphicsLayoutItem Class Referenceabstract

The QGraphicsLayoutItem class can be inherited to allow your custom items to be managed by layouts. More...

#include <qgraphicslayoutitem.h>

+ Inheritance diagram for QGraphicsLayoutItem:
+ Collaboration diagram for QGraphicsLayoutItem:

Public Member Functions

 QGraphicsLayoutItem (QGraphicsLayoutItem *parent=nullptr, bool isLayout=false)
 Constructs the QGraphicsLayoutItem object.
 
virtual ~QGraphicsLayoutItem ()
 Destroys the QGraphicsLayoutItem object.
 
void setSizePolicy (const QSizePolicy &policy)
 Sets the size policy to policy.
 
void setSizePolicy (QSizePolicy::Policy hPolicy, QSizePolicy::Policy vPolicy, QSizePolicy::ControlType controlType=QSizePolicy::DefaultType)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.This function is equivalent to calling setSizePolicy(QSizePolicy(hPolicy, vPolicy, controlType)).
 
QSizePolicy sizePolicy () const
 Returns the current size policy.
 
void setMinimumSize (const QSizeF &size)
 Sets the minimum size to size.
 
void setMinimumSize (qreal w, qreal h)
 This convenience function is equivalent to calling setMinimumSize(QSizeF(w, h)).
 
QSizeF minimumSize () const
 Returns the minimum size.
 
void setMinimumWidth (qreal width)
 Sets the minimum width to width.
 
qreal minimumWidth () const
 Returns the minimum width.
 
void setMinimumHeight (qreal height)
 Sets the minimum height to height.
 
qreal minimumHeight () const
 Returns the minimum height.
 
void setPreferredSize (const QSizeF &size)
 Sets the preferred size to size.
 
void setPreferredSize (qreal w, qreal h)
 This convenience function is equivalent to calling setPreferredSize(QSizeF(w, h)).
 
QSizeF preferredSize () const
 Returns the preferred size.
 
void setPreferredWidth (qreal width)
 Sets the preferred width to width.
 
qreal preferredWidth () const
 Returns the preferred width.
 
void setPreferredHeight (qreal height)
 Sets the preferred height to height.
 
qreal preferredHeight () const
 Returns the preferred height.
 
void setMaximumSize (const QSizeF &size)
 Sets the maximum size to size.
 
void setMaximumSize (qreal w, qreal h)
 This convenience function is equivalent to calling setMaximumSize(QSizeF(w, h)).
 
QSizeF maximumSize () const
 Returns the maximum size.
 
void setMaximumWidth (qreal width)
 Sets the maximum width to width.
 
qreal maximumWidth () const
 Returns the maximum width.
 
void setMaximumHeight (qreal height)
 Sets the maximum height to height.
 
qreal maximumHeight () const
 Returns the maximum height.
 
virtual void setGeometry (const QRectF &rect)
 This virtual function sets the geometry of the QGraphicsLayoutItem to rect, which is in parent coordinates (e.g., the top-left corner of rect is equivalent to the item's position in parent coordinates).
 
QRectF geometry () const
 Returns the item's geometry (e.g., position and size) as a QRectF.
 
virtual void getContentsMargins (qreal *left, qreal *top, qreal *right, qreal *bottom) const
 This virtual function provides the left, top, right and bottom contents margins for this QGraphicsLayoutItem.
 
QRectF contentsRect () const
 Returns the contents rect in local coordinates.
 
QSizeF effectiveSizeHint (Qt::SizeHint which, const QSizeF &constraint=QSizeF()) const
 Returns the effective size hint for this QGraphicsLayoutItem.
 
virtual void updateGeometry ()
 This virtual function discards any cached size hint information.
 
virtual bool isEmpty () const
 
QGraphicsLayoutItemparentLayoutItem () const
 Returns the parent of this QGraphicsLayoutItem, or \nullptr if there is no parent, or if the parent does not inherit from QGraphicsLayoutItem (QGraphicsLayoutItem is often used through multiple inheritance with QObject-derived classes).
 
void setParentLayoutItem (QGraphicsLayoutItem *parent)
 Sets the parent of this QGraphicsLayoutItem to parent.
 
bool isLayout () const
 Returns true if this QGraphicsLayoutItem is a layout (e.g., is inherited by an object that arranges other QGraphicsLayoutItem objects); otherwise returns false.
 
QGraphicsItemgraphicsItem () const
 Returns the QGraphicsItem that this layout item represents.
 
bool ownedByLayout () const
 

Protected Member Functions

void setGraphicsItem (QGraphicsItem *item)
 If the QGraphicsLayoutItem represents a QGraphicsItem, and it wants to take advantage of the automatic reparenting capabilities of QGraphicsLayout it should set this value.
 
void setOwnedByLayout (bool ownedByLayout)
 
 QGraphicsLayoutItem (QGraphicsLayoutItemPrivate &dd)
 
virtual QSizeF sizeHint (Qt::SizeHint which, const QSizeF &constraint=QSizeF()) const =0
 This pure virtual function returns the size hint for which of the QGraphicsLayoutItem, using the width or height of constraint to constrain the output.
 

Protected Attributes

QScopedPointer< QGraphicsLayoutItemPrivated_ptr
 

Friends

class QGraphicsLayout
 

Detailed Description

The QGraphicsLayoutItem class can be inherited to allow your custom items to be managed by layouts.

Since
4.4

\inmodule QtWidgets

QGraphicsLayoutItem is an abstract class that defines a set of virtual functions describing sizes, size policies, and size hints for any object arranged by QGraphicsLayout. The API contains functions relevant for both the item itself and for the user of the item as most of QGraphicsLayoutItem's functions are also part of the subclass' public API.

In most cases, existing layout-aware classes such as QGraphicsWidget and QGraphicsLayout already provide the functionality you require. However, subclassing these classes will enable you to create both graphical elements that work well with layouts (QGraphicsWidget) or custom layouts (QGraphicsLayout).

Definition at line 18 of file qgraphicslayoutitem.h.

Constructor & Destructor Documentation

◆ QGraphicsLayoutItem() [1/2]

QGraphicsLayoutItem::QGraphicsLayoutItem ( QGraphicsLayoutItem * parent = nullptr,
bool isLayout = false )

Constructs the QGraphicsLayoutItem object.

parent becomes the object's parent. If isLayout is true the item is a layout, otherwise isLayout is false.

Definition at line 354 of file qgraphicslayoutitem.cpp.

References d, and QSizePolicy::Preferred.

◆ ~QGraphicsLayoutItem()

QGraphicsLayoutItem::~QGraphicsLayoutItem ( )
virtual

Destroys the QGraphicsLayoutItem object.

Definition at line 377 of file qgraphicslayoutitem.cpp.

References i, parentLayoutItem(), and QGraphicsLayout::removeAt().

+ Here is the call graph for this function:

◆ QGraphicsLayoutItem() [2/2]

QGraphicsLayoutItem::QGraphicsLayoutItem ( QGraphicsLayoutItemPrivate & dd)
protected

Definition at line 366 of file qgraphicslayoutitem.cpp.

References d.

Member Function Documentation

◆ contentsRect()

QRectF QGraphicsLayoutItem::contentsRect ( ) const

Returns the contents rect in local coordinates.

The contents rect defines the subrectangle used by an associated layout when arranging subitems. This function is a convenience function that adjusts the item's geometry() by its contents margins. Note that getContentsMargins() is a virtual function that you can reimplement to return the item's contents margins.

See also
getContentsMargins(), geometry()

Definition at line 732 of file qgraphicslayoutitem.cpp.

References QRectF::adjusted(), geometry(), and getContentsMargins().

Referenced by QGraphicsLayout::activate(), and QGraphicsLayout::widgetEvent().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ effectiveSizeHint()

QSizeF QGraphicsLayoutItem::effectiveSizeHint ( Qt::SizeHint which,
const QSizeF & constraint = QSizeF() ) const

Returns the effective size hint for this QGraphicsLayoutItem.

which is the size hint in question. constraint is an optional argument that defines a special constrain when calculating the effective size hint. By default, constraint is QSizeF(-1, -1), which means there is no constraint to the size hint.

If you want to specify the widget's size hint for a given width or height, you can provide the fixed dimension in constraint. This is useful for widgets that can grow only either vertically or horizontally, and need to set either their width or their height to a special value.

For example, a text paragraph item fit into a column width of 200 may grow vertically. You can pass QSizeF(200, -1) as a constraint to get a suitable minimum, preferred and maximum height).

You can adjust the effective size hint by reimplementing sizeHint() in a QGraphicsLayoutItem subclass, or by calling one of the following functions: setMinimumSize(), setPreferredSize, or setMaximumSize() (or a combination of both).

This function caches each of the size hints and guarantees that sizeHint() will be called only once for each value of which - unless constraint is not specified and updateGeometry() has been called.

See also
sizeHint()

Definition at line 767 of file qgraphicslayoutitem.cpp.

References d, d_ptr, QGraphicsLayoutItemPrivate::effectiveSizeHints(), and QSizeF::isValid().

Referenced by QGraphicsWidget::adjustSize(), maximumSize(), minimumSize(), preferredSize(), QtGraphicsAnchorLayout::AnchorData::refreshSizeHints(), setGeometry(), and QGraphicsGridLayoutEngineItem::sizeHint().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ geometry()

QRectF QGraphicsLayoutItem::geometry ( ) const

Returns the item's geometry (e.g., position and size) as a QRectF.

This function is equivalent to QRectF(pos(), size()).

See also
setGeometry()

Definition at line 695 of file qgraphicslayoutitem.cpp.

References d.

Referenced by contentsRect(), QGraphicsGridLayout::setGeometry(), QGraphicsLinearLayout::setGeometry(), and QGraphicsWidget::size().

+ Here is the caller graph for this function:

◆ getContentsMargins()

void QGraphicsLayoutItem::getContentsMargins ( qreal * left,
qreal * top,
qreal * right,
qreal * bottom ) const
virtual

This virtual function provides the left, top, right and bottom contents margins for this QGraphicsLayoutItem.

The default implementation assumes all contents margins are 0. The parameters point to values stored in qreals. If any of the pointers is \nullptr, that value will not be updated.

See also
QGraphicsWidget::setContentsMargins()

Reimplemented in QGraphicsLayout, and QGraphicsWidget.

Definition at line 709 of file qgraphicslayoutitem.cpp.

Referenced by contentsRect().

+ Here is the caller graph for this function:

◆ graphicsItem()

QGraphicsItem * QGraphicsLayoutItem::graphicsItem ( ) const

Returns the QGraphicsItem that this layout item represents.

For QGraphicsWidget it will return itself. For custom items it can return an aggregated value.

See also
setGraphicsItem()

Definition at line 895 of file qgraphicslayoutitem.cpp.

Referenced by QGraphicsLayout::QGraphicsLayout(), QGraphicsLayout::QGraphicsLayout(), isEmpty(), QGraphicsLayoutItemPrivate::parentItem(), and QGraphicsAnchorLayoutPrivate::styleInfo().

+ Here is the caller graph for this function:

◆ isEmpty()

bool QGraphicsLayoutItem::isEmpty ( ) const
virtual
Since
6.0

Returns true if this item is empty, i.e whether it has no content and should not occupy any space.

The default implementation returns true true if the item has been hidden, unless its \l{sizePolicy()}{size policy} has retainSizeWhenHidden set to true

See also
sizePolicy()

Definition at line 804 of file qgraphicslayoutitem.cpp.

References QGraphicsItemPrivate::get(), graphicsItem(), item, QSizePolicy::retainSizeWhenHidden(), and sizePolicy().

Referenced by createReadHandlerHelper(), createWriteHandlerHelper(), and QGraphicsGridLayoutEngineItem::isEmpty().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ isLayout()

bool QGraphicsLayoutItem::isLayout ( ) const

Returns true if this QGraphicsLayoutItem is a layout (e.g., is inherited by an object that arranges other QGraphicsLayoutItem objects); otherwise returns false.

See also
QGraphicsLayout

Definition at line 843 of file qgraphicslayoutitem.cpp.

References isLayout().

Referenced by QGraphicsLayout::QGraphicsLayout(), QGraphicsLayout::QGraphicsLayout(), QGraphicsLayout::activate(), QGraphicsLayoutPrivate::getMargin(), isLayout(), QGraphicsLayoutItemPrivate::parentItem(), QGraphicsAnchorLayoutPrivate::styleInfo(), and QGraphicsLayout::updateGeometry().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ maximumHeight()

qreal QGraphicsLayoutItem::maximumHeight ( ) const
inline

Returns the maximum height.

See also
setMaximumHeight(), setMaximumSize(), maximumSize()

Definition at line 107 of file qgraphicslayoutitem.h.

References QSizeF::height(), and Qt::MaximumSize.

+ Here is the call graph for this function:

◆ maximumSize()

QSizeF QGraphicsLayoutItem::maximumSize ( ) const

Returns the maximum size.

See also
setMaximumSize(), minimumSize(), preferredSize(), Qt::MaximumSize, sizeHint()

Definition at line 589 of file qgraphicslayoutitem.cpp.

References effectiveSizeHint(), and Qt::MaximumSize.

+ Here is the call graph for this function:

◆ maximumWidth()

qreal QGraphicsLayoutItem::maximumWidth ( ) const
inline

Returns the maximum width.

See also
setMaximumWidth(), setMaximumSize(), maximumSize()

Definition at line 105 of file qgraphicslayoutitem.h.

References Qt::MaximumSize, and QSizeF::width().

+ Here is the call graph for this function:

◆ minimumHeight()

qreal QGraphicsLayoutItem::minimumHeight ( ) const
inline

Returns the minimum height.

See also
setMinimumHeight(), setMinimumSize(), minimumSize()

Definition at line 97 of file qgraphicslayoutitem.h.

References QSizeF::height(), and Qt::MinimumSize.

+ Here is the call graph for this function:

◆ minimumSize()

QSizeF QGraphicsLayoutItem::minimumSize ( ) const

Returns the minimum size.

See also
setMinimumSize(), preferredSize(), maximumSize(), Qt::MinimumSize, sizeHint()

Definition at line 481 of file qgraphicslayoutitem.cpp.

References effectiveSizeHint(), and Qt::MinimumSize.

+ Here is the call graph for this function:

◆ minimumWidth()

qreal QGraphicsLayoutItem::minimumWidth ( ) const
inline

Returns the minimum width.

See also
setMinimumWidth(), setMinimumSize(), minimumSize()

Definition at line 95 of file qgraphicslayoutitem.h.

References Qt::MinimumSize, and QSizeF::width().

+ Here is the call graph for this function:

◆ ownedByLayout()

bool QGraphicsLayoutItem::ownedByLayout ( ) const
Since
4.6

Returns whether a layout should delete this item in its destructor. If its true, then the layout will delete it. If its false, then it is assumed that another object has the ownership of it, and the layout won't delete this item.

If the item inherits both QGraphicsItem and QGraphicsLayoutItem (such as QGraphicsWidget does) the item is really part of two ownership hierarchies. This property informs what the layout should do with its child items when it is destructed. In the case of QGraphicsWidget, it is preferred that when the layout is deleted it won't delete its children (since they are also part of the graphics item hierarchy).

By default this value is initialized to false in QGraphicsLayoutItem, but it is overridden by QGraphicsLayout to return true. This is because QGraphicsLayout is not normally part of the QGraphicsItem hierarchy, so the parent layout should delete it. Subclasses might override this default behaviour by calling setOwnedByLayout(true).

See also
setOwnedByLayout()

Definition at line 872 of file qgraphicslayoutitem.cpp.

◆ parentLayoutItem()

QGraphicsLayoutItem * QGraphicsLayoutItem::parentLayoutItem ( ) const

Returns the parent of this QGraphicsLayoutItem, or \nullptr if there is no parent, or if the parent does not inherit from QGraphicsLayoutItem (QGraphicsLayoutItem is often used through multiple inheritance with QObject-derived classes).

See also
setParentLayoutItem()

Definition at line 821 of file qgraphicslayoutitem.cpp.

Referenced by ~QGraphicsLayoutItem(), QGraphicsLayout::activate(), QGraphicsAnchorLayoutPrivate::addAnchor(), QGraphicsLayoutPrivate::getMargin(), QGraphicsLayoutItemPrivate::parentItem(), QGraphicsWidget::setLayout(), QGraphicsAnchorLayoutPrivate::styleInfo(), QGraphicsLayout::updateGeometry(), QGraphicsWidget::updateGeometry(), and QGraphicsLayout::widgetEvent().

+ Here is the caller graph for this function:

◆ preferredHeight()

qreal QGraphicsLayoutItem::preferredHeight ( ) const
inline

Returns the preferred height.

See also
setPreferredHeight(), setPreferredSize(), preferredSize()

Definition at line 102 of file qgraphicslayoutitem.h.

References QSizeF::height(), and Qt::PreferredSize.

+ Here is the call graph for this function:

◆ preferredSize()

QSizeF QGraphicsLayoutItem::preferredSize ( ) const

Returns the preferred size.

See also
setPreferredSize(), minimumSize(), maximumSize(), Qt::PreferredSize, sizeHint()

Definition at line 535 of file qgraphicslayoutitem.cpp.

References effectiveSizeHint(), and Qt::PreferredSize.

+ Here is the call graph for this function:

◆ preferredWidth()

qreal QGraphicsLayoutItem::preferredWidth ( ) const
inline

Returns the preferred width.

See also
setPreferredWidth(), setPreferredSize(), preferredSize()

Definition at line 100 of file qgraphicslayoutitem.h.

References Qt::PreferredSize, and QSizeF::width().

+ Here is the call graph for this function:

◆ setGeometry()

void QGraphicsLayoutItem::setGeometry ( const QRectF & rect)
virtual

This virtual function sets the geometry of the QGraphicsLayoutItem to rect, which is in parent coordinates (e.g., the top-left corner of rect is equivalent to the item's position in parent coordinates).

You must reimplement this function in a subclass of QGraphicsLayoutItem to receive geometry updates. The layout will call this function when it does a rearrangement.

If rect is outside of the bounds of minimumSize and maximumSize, it will be adjusted to its closest size so that it is within the legal bounds.

See also
geometry()

Reimplemented in QGraphicsAnchorLayout, QGraphicsGridLayout, QGraphicsLinearLayout, QGraphicsProxyWidget, and QGraphicsWidget.

Definition at line 679 of file qgraphicslayoutitem.cpp.

References d, effectiveSizeHint(), QSizeF::expandedTo(), Qt::MaximumSize, Qt::MinimumSize, and rect.

Referenced by QGraphicsLayout::activate(), QGraphicsAnchorLayout::setGeometry(), QGraphicsGridLayout::setGeometry(), QGraphicsGridLayoutEngineItem::setGeometry(), QGraphicsLinearLayout::setGeometry(), and QGraphicsLayout::widgetEvent().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setGraphicsItem()

void QGraphicsLayoutItem::setGraphicsItem ( QGraphicsItem * item)
protected

If the QGraphicsLayoutItem represents a QGraphicsItem, and it wants to take advantage of the automatic reparenting capabilities of QGraphicsLayout it should set this value.

Note that if you delete item and not delete the layout item, you are responsible of calling setGraphicsItem(\nullptr) in order to avoid having a dangling pointer.

See also
graphicsItem()

Definition at line 910 of file qgraphicslayoutitem.cpp.

References item.

◆ setMaximumHeight()

void QGraphicsLayoutItem::setMaximumHeight ( qreal height)

Sets the maximum height to height.

See also
maximumHeight(), setMaximumSize(), maximumSize()

Definition at line 609 of file qgraphicslayoutitem.cpp.

References d_ptr, QGraphicsLayoutItemPrivate::Height, Qt::MaximumSize, and QGraphicsLayoutItemPrivate::setSizeComponent().

+ Here is the call graph for this function:

◆ setMaximumSize() [1/2]

void QGraphicsLayoutItem::setMaximumSize ( const QSizeF & size)

Sets the maximum size to size.

This property overrides sizeHint() for Qt::MaximumSize and ensures that effectiveSizeHint() will never return a size larger than size. In order to unset the maximum size, use an invalid size.

See also
maximumSize(), minimumSize(), preferredSize(), Qt::MaximumSize, sizeHint()

Definition at line 569 of file qgraphicslayoutitem.cpp.

References d_ptr, Qt::MaximumSize, and QGraphicsLayoutItemPrivate::setSize().

+ Here is the call graph for this function:

◆ setMaximumSize() [2/2]

void QGraphicsLayoutItem::setMaximumSize ( qreal w,
qreal h )
inline

This convenience function is equivalent to calling setMaximumSize(QSizeF(w, h)).

See also
maximumSize(), setMinimumSize(), setPreferredSize(), sizeHint()

Definition at line 92 of file qgraphicslayoutitem.h.

◆ setMaximumWidth()

void QGraphicsLayoutItem::setMaximumWidth ( qreal width)

Sets the maximum width to width.

See also
maximumWidth(), setMaximumSize(), maximumSize()

Definition at line 599 of file qgraphicslayoutitem.cpp.

References d_ptr, Qt::MaximumSize, QGraphicsLayoutItemPrivate::setSizeComponent(), and QGraphicsLayoutItemPrivate::Width.

+ Here is the call graph for this function:

◆ setMinimumHeight()

void QGraphicsLayoutItem::setMinimumHeight ( qreal height)

Sets the minimum height to height.

See also
minimumHeight(), setMinimumSize(), minimumSize()

Definition at line 501 of file qgraphicslayoutitem.cpp.

References d_ptr, QGraphicsLayoutItemPrivate::Height, Qt::MinimumSize, and QGraphicsLayoutItemPrivate::setSizeComponent().

+ Here is the call graph for this function:

◆ setMinimumSize() [1/2]

void QGraphicsLayoutItem::setMinimumSize ( const QSizeF & size)

Sets the minimum size to size.

This property overrides sizeHint() for Qt::MinimumSize and ensures that effectiveSizeHint() will never return a size smaller than size. In order to unset the minimum size, use an invalid size.

See also
minimumSize(), maximumSize(), preferredSize(), Qt::MinimumSize, sizeHint(), setMinimumWidth(), setMinimumHeight()

Definition at line 461 of file qgraphicslayoutitem.cpp.

References d_ptr, Qt::MinimumSize, and QGraphicsLayoutItemPrivate::setSize().

+ Here is the call graph for this function:

◆ setMinimumSize() [2/2]

void QGraphicsLayoutItem::setMinimumSize ( qreal w,
qreal h )
inline

This convenience function is equivalent to calling setMinimumSize(QSizeF(w, h)).

See also
minimumSize(), setMaximumSize(), setPreferredSize(), sizeHint()

Definition at line 88 of file qgraphicslayoutitem.h.

◆ setMinimumWidth()

void QGraphicsLayoutItem::setMinimumWidth ( qreal width)

Sets the minimum width to width.

See also
minimumWidth(), setMinimumSize(), minimumSize()

Definition at line 491 of file qgraphicslayoutitem.cpp.

References d_ptr, Qt::MinimumSize, QGraphicsLayoutItemPrivate::setSizeComponent(), and QGraphicsLayoutItemPrivate::Width.

+ Here is the call graph for this function:

◆ setOwnedByLayout()

void QGraphicsLayoutItem::setOwnedByLayout ( bool ownership)
protected
Since
4.6

Sets whether a layout should delete this item in its destructor or not. ownership must be true to in order for the layout to delete it.

See also
ownedByLayout()

Definition at line 883 of file qgraphicslayoutitem.cpp.

Referenced by QGraphicsLayout::QGraphicsLayout(), and QGraphicsLayout::QGraphicsLayout().

+ Here is the caller graph for this function:

◆ setParentLayoutItem()

void QGraphicsLayoutItem::setParentLayoutItem ( QGraphicsLayoutItem * parent)

Sets the parent of this QGraphicsLayoutItem to parent.

See also
parentLayoutItem()

Definition at line 831 of file qgraphicslayoutitem.cpp.

Referenced by QGraphicsLayout::QGraphicsLayout(), QGraphicsLayout::QGraphicsLayout(), and QGraphicsWidget::setLayout().

+ Here is the caller graph for this function:

◆ setPreferredHeight()

void QGraphicsLayoutItem::setPreferredHeight ( qreal height)

Sets the preferred height to height.

See also
preferredWidth(), setPreferredSize(), preferredSize()

Definition at line 545 of file qgraphicslayoutitem.cpp.

References d_ptr, QGraphicsLayoutItemPrivate::Height, Qt::PreferredSize, and QGraphicsLayoutItemPrivate::setSizeComponent().

+ Here is the call graph for this function:

◆ setPreferredSize() [1/2]

void QGraphicsLayoutItem::setPreferredSize ( const QSizeF & size)

Sets the preferred size to size.

This property overrides sizeHint() for Qt::PreferredSize and provides the default value for effectiveSizeHint(). In order to unset the preferred size, use an invalid size.

See also
preferredSize(), minimumSize(), maximumSize(), Qt::PreferredSize, sizeHint()

Definition at line 515 of file qgraphicslayoutitem.cpp.

References d_ptr, Qt::PreferredSize, and QGraphicsLayoutItemPrivate::setSize().

+ Here is the call graph for this function:

◆ setPreferredSize() [2/2]

void QGraphicsLayoutItem::setPreferredSize ( qreal w,
qreal h )
inline

This convenience function is equivalent to calling setPreferredSize(QSizeF(w, h)).

See also
preferredSize(), setMaximumSize(), setMinimumSize(), sizeHint()

Definition at line 90 of file qgraphicslayoutitem.h.

◆ setPreferredWidth()

void QGraphicsLayoutItem::setPreferredWidth ( qreal width)

Sets the preferred width to width.

See also
preferredHeight(), setPreferredSize(), preferredSize()

Definition at line 555 of file qgraphicslayoutitem.cpp.

References d_ptr, Qt::PreferredSize, QGraphicsLayoutItemPrivate::setSizeComponent(), and QGraphicsLayoutItemPrivate::Width.

+ Here is the call graph for this function:

◆ setSizePolicy() [1/2]

void QGraphicsLayoutItem::setSizePolicy ( const QSizePolicy & policy)

Sets the size policy to policy.

The size policy describes how the item should grow horizontally and vertically when arranged in a layout.

QGraphicsLayoutItem's default size policy is (QSizePolicy::Fixed, QSizePolicy::Fixed, QSizePolicy::DefaultType), but it is common for subclasses to change the default. For example, QGraphicsWidget defaults to (QSizePolicy::Preferred, QSizePolicy::Preferred, QSizePolicy::DefaultType).

See also
sizePolicy(), QWidget::sizePolicy()

Definition at line 417 of file qgraphicslayoutitem.cpp.

References d, policy, and updateGeometry().

Referenced by setSizePolicy().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setSizePolicy() [2/2]

void QGraphicsLayoutItem::setSizePolicy ( QSizePolicy::Policy hPolicy,
QSizePolicy::Policy vPolicy,
QSizePolicy::ControlType controlType = QSizePolicy::DefaultType )

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.This function is equivalent to calling setSizePolicy(QSizePolicy(hPolicy, vPolicy, controlType)).

See also
sizePolicy(), QWidget::sizePolicy()

Definition at line 434 of file qgraphicslayoutitem.cpp.

References setSizePolicy().

+ Here is the call graph for this function:

◆ sizeHint()

QSizeF QGraphicsLayoutItem::sizeHint ( Qt::SizeHint which,
const QSizeF & constraint = QSizeF() ) const
protectedpure virtual

This pure virtual function returns the size hint for which of the QGraphicsLayoutItem, using the width or height of constraint to constrain the output.

Reimplement this function in a subclass of QGraphicsLayoutItem to provide the necessary size hints for your items.

See also
effectiveSizeHint()

Implemented in QGraphicsAnchorLayout, QGraphicsGridLayout, QGraphicsLinearLayout, QGraphicsProxyWidget, and QGraphicsWidget.

◆ sizePolicy()

QSizePolicy QGraphicsLayoutItem::sizePolicy ( ) const

Returns the current size policy.

See also
setSizePolicy(), QWidget::sizePolicy()

Definition at line 446 of file qgraphicslayoutitem.cpp.

References d.

Referenced by QGraphicsGridLayoutEngineItem::controlTypes(), isEmpty(), QtGraphicsAnchorLayout::AnchorData::refreshSizeHints(), and QGraphicsGridLayoutEngineItem::sizePolicy().

+ Here is the caller graph for this function:

◆ updateGeometry()

void QGraphicsLayoutItem::updateGeometry ( )
virtual

This virtual function discards any cached size hint information.

You should always call this function if you change the return value of the sizeHint() function. Subclasses must always call the base implementation when reimplementing this function.

See also
effectiveSizeHint()

Reimplemented in QGraphicsLayout, and QGraphicsWidget.

Definition at line 786 of file qgraphicslayoutitem.cpp.

References d.

Referenced by QGraphicsLayout::activate(), setSizePolicy(), QGraphicsLayout::updateGeometry(), and QGraphicsWidget::updateGeometry().

+ Here is the caller graph for this function:

Friends And Related Symbol Documentation

◆ QGraphicsLayout

friend class QGraphicsLayout
friend

Definition at line 81 of file qgraphicslayoutitem.h.

Member Data Documentation

◆ d_ptr


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