Class: QgsLayoutItemComboBox

The QgsLayoutItemComboBox class is 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

Methods

allowEmptyItem

Returns True if the model includes the empty item choice.

currentItem

Returns the item currently selected in the combo box.

currentLayout

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

exceptedItemList

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

item

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

itemFlags

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

itemType

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

setAllowEmptyItem

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

setCurrentLayout

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

setExceptedItemList

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

setItem

Sets the currently selected item in the combo box.

setItemFlags

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

setItemType

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

Signals

itemChanged

Emitted whenever the currently selected item changes

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(item: QgsLayoutItem)[source]

Emitted whenever the currently selected item changes

Parameters:

item (QgsLayoutItem)

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