Class: QgsCheckableComboBox

QComboBox subclass which allows selecting multiple items.

Class Hierarchy

Inheritance diagram of qgis.gui.QgsCheckableComboBox

Base classes

QComboBox

QWidget

QObject

QPaintDevice

Methods

addItemWithCheckState

Adds an item to the combobox with the given text, check state (stored in the Qt.CheckStateRole) and containing the specified userData (stored in the Qt.UserRole).

checkedItems

Returns currently checked items.

checkedItemsData

Returns userData (stored in the Qt.UserRole) associated with currently checked items.

defaultText

Returns default text which will be displayed in the widget when no items selected.

deselectAllOptions

Removes selection from all items.

itemCheckState

Returns the checked state of the item identified by index

selectAllOptions

Selects all items.

separator

Returns separator used to separate items in the display text.

setCheckedItems

Set items which should be checked/selected.

setDefaultText

Set default text which will be displayed in the widget when no items selected.

setItemCheckState

Sets the item check state to state

setSeparator

Set separator used to separate items in the display text.

showContextMenu

Display context menu which allows selecting/deselecting all items at once.

toggleItemCheckState

Toggles the item check state

Virtual Methods

In PyQGIS, only methods marked as virtual can be safely overridden in a Python subclass of QgsCheckableComboBox. See the FAQ for more details.

eventFilter

Filters events to enable context menu

hidePopup

Hides the list of items in the combobox if it is currently visible and resets the internal state.

resizeEvent

Handler for widget resizing

Signals

checkedItemsChanged

Emitted whenever the checked items list changed.

class qgis.gui.QgsCheckableComboBox[source]

Bases: QComboBox

__init__(parent: QWidget | None = None)

Constructor for QgsCheckableComboBox.

Parameters:

parent (Optional[QWidget] = None)

addItemWithCheckState(self, text: str | None, state: Qt.CheckState, userData: Any = None)[source]

Adds an item to the combobox with the given text, check state (stored in the Qt.CheckStateRole) and containing the specified userData (stored in the Qt.UserRole). The item is appended to the list of existing items.

Added in version 3.16.

Parameters:
  • text (Optional[str])

  • state (Qt.CheckState)

  • userData (Any = None)

checkedItems(self) List[str][source]

Returns currently checked items.

Return type:

List[str]

signal checkedItemsChanged(items: List[str])[source]

Emitted whenever the checked items list changed.

Parameters:

items (List[str])

checkedItemsData(self) List[Any][source]

Returns userData (stored in the Qt.UserRole) associated with currently checked items.

See also

checkedItems()

Return type:

List[Any]

defaultText(self) str[source]

Returns default text which will be displayed in the widget when no items selected.

See also

setDefaultText()

Return type:

str

deselectAllOptions(self)[source]

Removes selection from all items.

virtual eventFilter(self, object: QObject | None, event: QEvent | None) bool[source]

Filters events to enable context menu

Parameters:
  • object (Optional[QObject])

  • event (Optional[QEvent])

Return type:

bool

virtual hidePopup(self)[source]

Hides the list of items in the combobox if it is currently visible and resets the internal state.

itemCheckState(self, index: int) Qt.CheckState[source]

Returns the checked state of the item identified by index

Parameters:

index (int) – item index

Return type:

Qt.CheckState

virtual resizeEvent(self, event: QResizeEvent | None)[source]

Handler for widget resizing

Parameters:

event (Optional[QResizeEvent])

selectAllOptions(self)[source]

Selects all items.

separator(self) str[source]

Returns separator used to separate items in the display text.

See also

setSeparator()

Return type:

str

setCheckedItems(self, items: Iterable[str | None])[source]

Set items which should be checked/selected.

Parameters:

items (Iterable[Optional[str]]) – items to select

See also

checkedItems()

setDefaultText(self, text: str | None)[source]

Set default text which will be displayed in the widget when no items selected.

Parameters:

text (Optional[str]) – default text

See also

defaultText()

setItemCheckState(self, index: int, state: Qt.CheckState)[source]

Sets the item check state to state

Parameters:
  • index (int) – item index

  • state (Qt.CheckState) – check state

See also

itemCheckState()

setSeparator(self, separator: str | None)[source]

Set separator used to separate items in the display text.

Parameters:

separator (Optional[str]) – separator to use

See also

separator()

showContextMenu(self, pos: QPoint)[source]

Display context menu which allows selecting/deselecting all items at once.

Parameters:

pos (QPoint)

toggleItemCheckState(self, index: int)[source]

Toggles the item check state

Parameters:

index (int) – item index

See also

itemCheckState()