Class: QgsLayoutProxyModel

Allows for filtering a QgsLayoutModel by item type.

Class Hierarchy

Inheritance diagram of qgis.core.QgsLayoutProxyModel

Base classes

QSortFilterProxyModel

QAbstractProxyModel

QAbstractItemModel

QObject

class qgis.core.QgsLayoutProxyModel[source]

Bases: QSortFilterProxyModel

__init__(layout: QgsLayout | None, parent: QObject | None = None)

Constructor for QgsLayoutProxyModelm, attached to the specified layout.

Parameters:
  • layout (Optional[QgsLayout])

  • parent (Optional[QObject] = None)

allowEmptyItem(self) bool[source]

Returns True if the model includes the empty item choice.

Added in version 3.8.

Return type:

bool

exceptedItemList(self) List[QgsLayoutItem]

Returns the list of specific items excluded from the model.

Return type:

List[QgsLayoutItem]

filterType(self) QgsLayoutItemRegistry.ItemType[source]

Returns the current item type filter, or QgsLayoutItemRegistry.LayoutItem if no item type filter is set.

See also

setFilterType()

Return type:

QgsLayoutItemRegistry.ItemType

itemFlags(self) QgsLayoutItem.Flags[source]

Returns the layout item flags used for filtering the available items.

Returns None if no flag based filtering is occurring.

See also

setItemFlags()

Added in version 3.16.

Return type:

QgsLayoutItem.Flags

itemFromSourceIndex(self, sourceIndex: QModelIndex) QgsLayoutItem | None[source]

Returns the QgsLayoutItem corresponding to an index from the source QgsLayoutModel model.

Parameters:

sourceIndex (QModelIndex)

Return type:

Optional[QgsLayoutItem]

layout(self) QgsLayout | None[source]

Returns the associated layout.

Added in version 3.8.

Return type:

Optional[QgsLayout]

setAllowEmptyItem(self, allowEmpty: bool)[source]

Sets whether an optional empty layout item is present in the model.

See also

allowEmptyItem()

Added in version 3.8.

Parameters:

allowEmpty (bool)

setExceptedItemList(self, items: Iterable[QgsLayoutItem])[source]

Sets a list of specific items to exclude from the model.

Parameters:

items (Iterable[QgsLayoutItem])

setFilterType(self, filter: QgsLayoutItemRegistry.ItemType)[source]

Sets the item type filter. Only matching item types will be shown. Set filter to QgsLayoutItemRegistry.LayoutItem to show all item types.

See also

filterType()

Parameters:

filter (QgsLayoutItemRegistry.ItemType)

setItemFlags(self, flags: QgsLayoutItem.Flags | QgsLayoutItem.Flag)[source]

Sets layout item flags to use for filtering the available items.

Set flags to None to clear the flag based filtering.

See also

itemFlags()

Added in version 3.16.

Parameters:

flags (Union[QgsLayoutItem.Flags, QgsLayoutItem.Flag])

sourceLayerModel(self) QgsLayoutModel | None[source]

Returns the QgsLayoutModel used in this proxy model.

Return type:

Optional[QgsLayoutModel]