Class: QgsCheckableComboBox

QComboBox subclass which allows selecting multiple items.

Class Hierarchy

Inheritance diagram of qgis.gui.QgsCheckableComboBox

Base classes

QComboBox

QWidget

QObject

QPaintDevice

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

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