QLayoutItem

Inheritance diagram of QLayoutItem

Inherited by: QWidgetItem, QSpacerItem, QLayout, QStackedLayout, QGridLayout, QFormLayout, QBoxLayout, QVBoxLayout, QHBoxLayout

Synopsis

Functions

Virtual functions

Detailed Description

The PySide.QtGui.QLayoutItem class provides an abstract item that a PySide.QtGui.QLayout manipulates.

This is used by custom layouts.

Pure virtual functions are provided to return information about the layout, including, PySide.QtGui.QLayoutItem.sizeHint() , PySide.QtGui.QLayoutItem.minimumSize() , PySide.QtGui.QLayoutItem.maximumSize() and expanding().

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

PySide.QtGui.QLayoutItem.isEmpty() returns whether the layout item is empty. If the concrete item is a PySide.QtGui.QWidget , it can be retrieved using PySide.QtGui.QLayoutItem.widget() . Similarly for PySide.QtGui.QLayoutItem.layout() and PySide.QtGui.QLayoutItem.spacerItem() .

Some layouts have width and height interdependencies. These can be expressed using PySide.QtGui.QLayoutItem.hasHeightForWidth() , PySide.QtGui.QLayoutItem.heightForWidth() , and PySide.QtGui.QLayoutItem.minimumHeightForWidth() . For more explanation see the Qt Quarterly article Trading Height for Width.

class PySide.QtGui.QLayoutItem([alignment=0])
Parameters:alignmentPySide.QtCore.Qt.Alignment
PySide.QtGui.QLayoutItem.align
PySide.QtGui.QLayoutItem.alignment()
Return type:PySide.QtCore.Qt.Alignment

Returns the alignment of this item.

PySide.QtGui.QLayoutItem.controlTypes()
Return type:PySide.QtGui.QSizePolicy.ControlTypes

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

PySide.QtGui.QLayoutItem.expandingDirections()
Return type:PySide.QtCore.Qt.Orientations

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

PySide.QtGui.QLayoutItem.geometry()
Return type:PySide.QtCore.QRect

Returns the rectangle covered by this layout item.

PySide.QtGui.QLayoutItem.hasHeightForWidth()
Return type:PySide.QtCore.bool

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

PySide.QtGui.QLayoutItem.heightForWidth(arg__1)
Parameters:arg__1PySide.QtCore.int
Return type:PySide.QtCore.int

Returns the preferred height for this layout item, given the width w .

The default implementation returns -1, indicating that the preferred height is independent of the width of the item. Using the function PySide.QtGui.QLayoutItem.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.

PySide.QtGui.QLayoutItem.invalidate()

Invalidates any cached information in this layout item.

PySide.QtGui.QLayoutItem.isEmpty()
Return type:PySide.QtCore.bool

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

PySide.QtGui.QLayoutItem.layout()
Return type:PySide.QtGui.QLayout

If this item is a PySide.QtGui.QLayout , it is returned as a PySide.QtGui.QLayout ; otherwise 0 is returned. This function provides type-safe casting.

PySide.QtGui.QLayoutItem.maximumSize()
Return type:PySide.QtCore.QSize

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

PySide.QtGui.QLayoutItem.minimumHeightForWidth(arg__1)
Parameters:arg__1PySide.QtCore.int
Return type:PySide.QtCore.int

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

PySide.QtGui.QLayoutItem.minimumSize()
Return type:PySide.QtCore.QSize

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

PySide.QtGui.QLayoutItem.setAlignment(a)
Parameters:aPySide.QtCore.Qt.Alignment
PySide.QtGui.QLayoutItem.setGeometry(arg__1)
Parameters:arg__1PySide.QtCore.QRect

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

PySide.QtGui.QLayoutItem.sizeHint()
Return type:PySide.QtCore.QSize

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

PySide.QtGui.QLayoutItem.spacerItem()
Return type:PySide.QtGui.QSpacerItem

If this item is a PySide.QtGui.QSpacerItem , it is returned as a PySide.QtGui.QSpacerItem ; otherwise 0 is returned. This function provides type-safe casting.

PySide.QtGui.QLayoutItem.widget()
Return type:PySide.QtGui.QWidget

If this item is a PySide.QtGui.QWidget , it is returned as a PySide.QtGui.QWidget ; otherwise 0 is returned. This function provides type-safe casting.