内容表

上一话题

QLayout

下一话题

QLineEdit

QLayoutItem

QLayoutItem class provides an abstract item that a QLayout 操纵。 更多

Inheritance diagram of PySide2.QtWidgets.QLayoutItem

继承者: QSpacerItem , QWidgetItem

详细描述

这被用于自定义布局。

纯虚函数被提供以返回布局有关信息,包括: sizeHint() , minimumSize() , maximumSize() and expanding().

The layout’s geometry can be set and retrieved with setGeometry() and geometry() , and its alignment with setAlignment() and alignment() .

isEmpty() returns whether the layout item is empty. If the concrete item is a QWidget ,它可以被检索使用 widget() . Similarly for layout() and spacerItem() .

某些布局的宽度和高度是相互依赖的。这些可以被表达,使用 hasHeightForWidth() , heightForWidth() ,和 minimumHeightForWidth() . For more explanation see the Qt 季刊 文章 交易高度为宽度 .

另请参阅

QLayout

class QLayoutItem ( [ alignment=Qt.Alignment() ] )
param alignment

Alignment

构造布局项采用 alignment 。并非所有子类都支持对齐。

PySide2.QtWidgets.QLayoutItem. align
PySide2.QtWidgets.QLayoutItem. alignment ( )
返回类型

Alignment

返回此项的对齐方式。

另请参阅

setAlignment()

PySide2.QtWidgets.QLayoutItem. controlTypes ( )
返回类型

ControlTypes

Returns the control type(s) for the layout item. For a QWidgetItem , the control type comes from the widget’s size policy; for a QLayoutItem , the control types is derived from the layout’s contents.

另请参阅

controlType()

PySide2.QtWidgets.QLayoutItem. expandingDirections ( )
返回类型

Orientations

Returns whether this layout item can make use of more space than sizeHint() . A value of Vertical or Horizontal means that it wants to grow in only one dimension, whereas Vertical | Horizontal means that it wants to grow in both dimensions.

PySide2.QtWidgets.QLayoutItem. geometry ( )
返回类型

QRect

Returns the rectangle covered by this layout item.

另请参阅

setGeometry()

PySide2.QtWidgets.QLayoutItem. hasHeightForWidth ( )
返回类型

bool

返回 true if this layout’s preferred height depends on its width; otherwise returns false . The default implementation returns false.

Reimplement this function in layout managers that support height for width.

PySide2.QtWidgets.QLayoutItem. heightForWidth ( arg__1 )
参数

arg__1 int

返回类型

int

Returns the preferred height for this layout item, given the width, which is not used in this default implementation.

The default implementation returns -1, indicating that the preferred height is independent of the width of the item. Using the function hasHeightForWidth() will typically be much faster than calling this function and testing for -1.

Reimplement this function in layout managers that support height for width. A typical implementation will look like this:

def heightForWidth(self, w):
    if cache_dirty or cached_width != w:
        h = calculateHeightForWidth(w)
        self.cached_hfw = h
        return h
    return cached_hfw
											

Caching is strongly recommended; without it layout will take exponential time.

PySide2.QtWidgets.QLayoutItem. invalidate ( )

Invalidates any cached information in this layout item.

PySide2.QtWidgets.QLayoutItem. isEmpty ( )
返回类型

bool

Implemented in subclasses to return whether this item is empty, i.e. whether it contains any widgets.

PySide2.QtWidgets.QLayoutItem. layout ( )
返回类型

QLayout

若此项是 QLayout , it is returned as a QLayout ;否则 None is returned. This function provides type-safe casting.

PySide2.QtWidgets.QLayoutItem. maximumSize ( )
返回类型

QSize

Implemented in subclasses to return the maximum size of this item.

PySide2.QtWidgets.QLayoutItem. minimumHeightForWidth ( arg__1 )
参数

arg__1 int

返回类型

int

Returns the minimum height this widget needs for the given width, w . The default implementation simply returns heightForWidth ( w ).

PySide2.QtWidgets.QLayoutItem. minimumSize ( )
返回类型

QSize

Implemented in subclasses to return the minimum size of this item.

PySide2.QtWidgets.QLayoutItem. setAlignment ( a )
参数

a Alignment

把此项的对齐方式设为 alignment .

注意

Item alignment is only supported by QLayoutItem subclasses where it would have a visual effect. Except for QSpacerItem , which provides blank space for layouts, all public Qt classes that inherit QLayoutItem support item alignment.

另请参阅

alignment()

PySide2.QtWidgets.QLayoutItem. setGeometry ( arg__1 )
参数

arg__1 QRect

Implemented in subclasses to set this item’s geometry to r .

另请参阅

geometry()

PySide2.QtWidgets.QLayoutItem. sizeHint ( )
返回类型

QSize

Implemented in subclasses to return the preferred size of this item.

PySide2.QtWidgets.QLayoutItem. spacerItem ( )
返回类型

QSpacerItem

若此项是 QSpacerItem , it is returned as a QSpacerItem ;否则 None is returned. This function provides type-safe casting.

PySide2.QtWidgets.QLayoutItem. widget ( )
返回类型

QWidget

若此项管理 QWidget , returns that widget. Otherwise, None 被返回。

注意

While the functions layout() and spacerItem() perform casts, this function returns another object: QLayout and QSpacerItem inherit QLayoutItem ,而 QWidget does not.