Class: QgsLayoutItemComboBox

A combo box which displays items of a matching type from a layout.

QgsLayoutItemComboBox in the collapsed state

QgsLayoutItemComboBox in the collapsed state

QgsLayoutItemComboBox in the expanded state

QgsLayoutItemComboBox in the expanded state

Class Hierarchy

Inheritance diagram of qgis.gui.QgsLayoutItemComboBox

Base classes

QComboBox

QWidget

QObject

QPaintDevice

class qgis.gui.QgsLayoutItemComboBox[source]

Bases: QComboBox

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

QgsLayoutItemComboBox creates a combo box to display a list of items in a layout. The items can optionally be filtered by type. If layout is not set, no items will be shown until setCurrentLayout() is called

Parameters:
  • parent (Optional[QWidget] = None)

  • layout (Optional[QgsLayout] = None)

allowEmptyItem(self) bool[source]

Returns True if the model includes the empty item choice.

Added in version 3.8.

Return type:

bool

currentItem(self) QgsLayoutItem | None[source]

Returns the item currently selected in the combo box.

Return type:

Optional[QgsLayoutItem]

currentLayout(self) QgsLayout | None[source]

Returns the current layout containing the items shown in the combo box.

Return type:

Optional[QgsLayout]

exceptedItemList(self) List[QgsLayoutItem]

Returns the list of specific items excluded from the combo box.

Return type:

List[QgsLayoutItem]

item(self, index: int) QgsLayoutItem | None[source]

Returns the item currently shown at the specified index within the combo box.

See also

currentItem()

Parameters:

index (int)

Return type:

Optional[QgsLayoutItem]

signal itemChanged[source]

pyqtSignal(*types, name: str = …, revision: int = …, arguments: Sequence = …) -> PYQT_SIGNAL

types is normally a sequence of individual types. Each type is either a type object or a string that is the name of a C++ type. Alternatively each type could itself be a sequence of types each describing a different overloaded signal. name is the optional C++ name of the signal. If it is not specified then the name of the class attribute that is bound to the signal is used. revision is the optional revision of the signal that is exported to QML. If it is not specified then 0 is used. arguments is the optional sequence of the names of the signal’s arguments.

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

itemType(self) QgsLayoutItemRegistry.ItemType[source]

Returns the filter for the item types to show in the combo box.

See also

setItemType()

Return type:

QgsLayoutItemRegistry.ItemType

setAllowEmptyItem(self, allowEmpty: bool)[source]

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

See also

allowEmptyItem()

Added in version 3.8.

Parameters:

allowEmpty (bool)

setCurrentLayout(self, layout: QgsLayout | None)[source]

Sets the layout containing the items to list in the combo box.

See also

currentLayout()

Parameters:

layout (Optional[QgsLayout])

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

Sets a list of specific items to exclude from the combo box.

Parameters:

exceptList (Iterable[QgsLayoutItem])

setItem(self, item: QgsLayoutItem | None)[source]

Sets the currently selected item in the combo box.

Parameters:

item (Optional[QgsLayoutItem])

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])

setItemType(self, itemType: QgsLayoutItemRegistry.ItemType)[source]

Sets a filter for the item type to show in the combo box.

Parameters:

itemType (QgsLayoutItemRegistry.ItemType) – type of items to show. Set to QgsLayoutItemRegistry.LayoutItem to show all items.

See also

itemType()