QGraphicsLayoutItem

继承者: QGraphicsLayout , QGraphicsLinearLayout , QGraphicsGridLayout , QGraphicsAnchorLayout , QGraphicsWidget , QGraphicsProxyWidget , QGraphicsWebView

概要

函数

虚函数

详细描述

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

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

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

子类化 QGraphicsLayoutItem

If you create a subclass of PySide.QtGui.QGraphicsLayoutItem and reimplement its virtual functions, you will enable the layout to resize and position your item along with other QGraphicsLayoutItems including PySide.QtGui.QGraphicsWidget and PySide.QtGui.QGraphicsLayout .

You can start by reimplementing important functions: the protected PySide.QtGui.QGraphicsLayoutItem.sizeHint() function, as well as the public PySide.QtGui.QGraphicsLayoutItem.setGeometry() function. If you want your items to be aware of immediate geometry changes, you can also reimplement PySide.QtGui.QGraphicsLayoutItem.updateGeometry() .

The geometry, size hint, and size policy affect the item's size and position. Calling PySide.QtGui.QGraphicsLayoutItem.setGeometry() will always resize and reposition the item immediately. Normally, this function is called by PySide.QtGui.QGraphicsLayout after the layout has been activated, but it can also be called by the item's user at any time.

PySide.QtGui.QGraphicsLayoutItem.sizeHint() function returns the item' minimum, preferred and maximum size hints. You can override these properties by calling PySide.QtGui.QGraphicsLayoutItem.setMinimumSize() , PySide.QtGui.QGraphicsLayoutItem.setPreferredSize() or PySide.QtGui.QGraphicsLayoutItem.setMaximumSize() . You can also use functions such as PySide.QtGui.QGraphicsLayoutItem.setMinimumWidth() or PySide.QtGui.QGraphicsLayoutItem.setMaximumHeight() to set only the width or height component if desired.

PySide.QtGui.QGraphicsLayoutItem.effectiveSizeHint() function, on the other hand, returns a size hint for any given Qt.SizeHint , and guarantees that the returned size is bound to the minimum and maximum sizes and size hints. You can set the item's vertical and horizontal size policy by calling PySide.QtGui.QGraphicsLayoutItem.setSizePolicy() . The sizePolicy property is used by the layout system to describe how this item prefers to grow or shrink.

嵌套 QGraphicsLayoutItems

QGraphicsLayoutItems can be nested within other QGraphicsLayoutItems, similar to layouts that can contain sublayouts. This is done either by passing a PySide.QtGui.QGraphicsLayoutItem pointer to PySide.QtGui.QGraphicsLayoutItem ‘s protected constructor, or by calling PySide.QtGui.QGraphicsLayoutItem.setParentLayoutItem() PySide.QtGui.QGraphicsLayoutItem.parentLayoutItem() function returns a pointer to the item's layoutItem parent. If the item's parent is 0 or if the parent does not inherit from PySide.QtGui.QGraphicsItem PySide.QtGui.QGraphicsLayoutItem.parentLayoutItem() function then returns 0. PySide.QtGui.QGraphicsLayoutItem.isLayout() returns true if the PySide.QtGui.QGraphicsLayoutItem subclass is itself a layout, or false otherwise.

Qt uses PySide.QtGui.QGraphicsLayoutItem to provide layout functionality in the 图形视图框架 , but in the future its use may spread throughout Qt itself.

class PySide.QtGui. QGraphicsLayoutItem ( [ parent=None [ , isLayout=false ] ] )
参数:

构造 PySide.QtGui.QGraphicsLayoutItem 对象。 parent becomes the object's parent. If isLayout is true the item is a layout, otherwise isLayout is false.

PySide.QtGui.QGraphicsLayoutItem. contentsRect ( )
返回类型: PySide.QtCore.QRectF

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 PySide.QtGui.QGraphicsLayoutItem.geometry() by its contents margins. Note that PySide.QtGui.QGraphicsLayoutItem.getContentsMargins() is a virtual function that you can reimplement to return the item's contents margins.

PySide.QtGui.QGraphicsLayoutItem. effectiveSizeHint ( which [ , constraint=QSizeF() ] )
参数:
返回类型:

PySide.QtCore.QSizeF

PySide.QtGui.QGraphicsLayoutItem. effectiveSizeHints ( constraint )
参数: constraint PySide.QtCore.QSizeF
返回类型: PySide.QtCore.QSizeF
PySide.QtGui.QGraphicsLayoutItem. geometry ( )
返回类型: PySide.QtCore.QRectF

Returns the item's geometry (e.g., position and size) as a PySide.QtCore.QRectF . This function is equivalent to PySide.QtCore.QRectF (pos(), size() ).

PySide.QtGui.QGraphicsLayoutItem. getContentsMargins ( )

This virtual function provides the left , top , right and bottom contents margins for this PySide.QtGui.QGraphicsLayoutItem . The default implementation assumes all contents margins are 0. The parameters point to values stored in qreals. If any of the pointers is 0, that value will not be updated.

PySide.QtGui.QGraphicsLayoutItem. graphicsItem ( )
返回类型: PySide.QtGui.QGraphicsItem

返回 PySide.QtGui.QGraphicsItem that this layout item represents. For PySide.QtGui.QGraphicsWidget it will return itself. For custom items it can return an aggregated value.

PySide.QtGui.QGraphicsLayoutItem. isLayout ( )
返回类型: PySide.QtCore.bool

返回 true,若此 PySide.QtGui.QGraphicsLayoutItem is a layout (e.g., is inherited by an object that arranges other PySide.QtGui.QGraphicsLayoutItem objects); otherwise returns false.

PySide.QtGui.QGraphicsLayoutItem. maximumHeight ( )
返回类型: PySide.QtCore.qreal

Returns the maximum height.

PySide.QtGui.QGraphicsLayoutItem. maximumSize ( )
返回类型: PySide.QtCore.QSizeF

Returns the maximum size.

PySide.QtGui.QGraphicsLayoutItem. maximumWidth ( )
返回类型: PySide.QtCore.qreal

Returns the maximum width.

PySide.QtGui.QGraphicsLayoutItem. minimumHeight ( )
返回类型: PySide.QtCore.qreal

Returns the minimum height.

PySide.QtGui.QGraphicsLayoutItem. minimumSize ( )
返回类型: PySide.QtCore.QSizeF

Returns the minimum size.

PySide.QtGui.QGraphicsLayoutItem. minimumWidth ( )
返回类型: PySide.QtCore.qreal

Returns the minimum width.

PySide.QtGui.QGraphicsLayoutItem. ownedByLayout ( )
返回类型: PySide.QtCore.bool

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 PySide.QtGui.QGraphicsItem and PySide.QtGui.QGraphicsLayoutItem (譬如 PySide.QtGui.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 PySide.QtGui.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 PySide.QtGui.QGraphicsLayoutItem , but it is overridden by PySide.QtGui.QGraphicsLayout to return true. This is because PySide.QtGui.QGraphicsLayout is not normally part of the PySide.QtGui.QGraphicsItem hierarchy, so the parent layout should delete it. Subclasses might override this default behaviour by calling setOwnedByLayout(true).

PySide.QtGui.QGraphicsLayoutItem. parentLayoutItem ( )
返回类型: PySide.QtGui.QGraphicsLayoutItem

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

PySide.QtGui.QGraphicsLayoutItem. preferredHeight ( )
返回类型: PySide.QtCore.qreal

Returns the preferred height.

PySide.QtGui.QGraphicsLayoutItem. preferredSize ( )
返回类型: PySide.QtCore.QSizeF

Returns the preferred size.

PySide.QtGui.QGraphicsLayoutItem. preferredWidth ( )
返回类型: PySide.QtCore.qreal

Returns the preferred width.

PySide.QtGui.QGraphicsLayoutItem. setGeometry ( rect )
参数: rect PySide.QtCore.QRectF

This virtual function sets the geometry of the PySide.QtGui.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 PySide.QtGui.QGraphicsLayoutItem to receive geometry updates. The layout will call this function when it does a rearrangement.

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.

PySide.QtGui.QGraphicsLayoutItem. setGraphicsItem ( item )
参数: item PySide.QtGui.QGraphicsItem

PySide.QtGui.QGraphicsLayoutItem represents a PySide.QtGui.QGraphicsItem , and it wants to take advantage of the automatic reparenting capabilities of PySide.QtGui.QGraphicsLayout it should set this value. Note that if you delete item and not delete the layout item, you are responsible of calling setGraphicsItem(0) in order to avoid having a dangling pointer.

PySide.QtGui.QGraphicsLayoutItem. setMaximumHeight ( height )
参数: height PySide.QtCore.qreal

Sets the maximum height to height .

PySide.QtGui.QGraphicsLayoutItem. setMaximumSize ( w , h )
参数:
  • w PySide.QtCore.qreal
  • h PySide.QtCore.qreal

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

PySide.QtGui.QGraphicsLayoutItem. setMaximumSize ( size )
参数: size PySide.QtCore.QSizeF

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

PySide.QtGui.QGraphicsLayoutItem. setMaximumWidth ( width )
参数: width PySide.QtCore.qreal

Sets the maximum width to width .

PySide.QtGui.QGraphicsLayoutItem. setMinimumHeight ( height )
参数: height PySide.QtCore.qreal

Sets the minimum height to height .

PySide.QtGui.QGraphicsLayoutItem. setMinimumSize ( size )
参数: size PySide.QtCore.QSizeF

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

PySide.QtGui.QGraphicsLayoutItem. setMinimumSize ( w , h )
参数:
  • w PySide.QtCore.qreal
  • h PySide.QtCore.qreal

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

PySide.QtGui.QGraphicsLayoutItem. setMinimumWidth ( width )
参数: width PySide.QtCore.qreal

Sets the minimum width to width .

PySide.QtGui.QGraphicsLayoutItem. setOwnedByLayout ( ownedByLayout )
参数: ownedByLayout PySide.QtCore.bool

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.

PySide.QtGui.QGraphicsLayoutItem. setParentLayoutItem ( parent )
参数: parent PySide.QtGui.QGraphicsLayoutItem

Sets the parent of this PySide.QtGui.QGraphicsLayoutItem to parent .

PySide.QtGui.QGraphicsLayoutItem. setPreferredHeight ( height )
参数: height PySide.QtCore.qreal

Sets the preferred height to height .

PySide.QtGui.QGraphicsLayoutItem. setPreferredSize ( w , h )
参数:
  • w PySide.QtCore.qreal
  • h PySide.QtCore.qreal

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

PySide.QtGui.QGraphicsLayoutItem. setPreferredSize ( size )
参数: size PySide.QtCore.QSizeF

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

PySide.QtGui.QGraphicsLayoutItem. setPreferredWidth ( width )
参数: width PySide.QtCore.qreal

Sets the preferred width to width .

PySide.QtGui.QGraphicsLayoutItem. setSizePolicy ( policy )
参数: policy PySide.QtGui.QSizePolicy

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

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

PySide.QtGui.QGraphicsLayoutItem. setSizePolicy ( hPolicy , vPolicy [ , controlType=QSizePolicy.DefaultType ] )
参数:
PySide.QtGui.QGraphicsLayoutItem. sizeHint ( which [ , constraint=QSizeF() ] )
参数:
返回类型:

PySide.QtCore.QSizeF

PySide.QtGui.QGraphicsLayoutItem. sizePolicy ( )
返回类型: PySide.QtGui.QSizePolicy

Returns the current size policy.

PySide.QtGui.QGraphicsLayoutItem. updateGeometry ( )

This virtual function discards any cached size hint information. You should always call this function if you change the return value of the PySide.QtGui.QGraphicsLayoutItem.sizeHint() function. Subclasses must always call the base implementation when reimplementing this function.