QgsCheckableComboBox class

QComboBox subclass which allows selecting multiple items.

Constructors, destructors, conversion operators

QgsCheckableComboBox(QWidget* parent = nullptr)
Constructor for QgsCheckableComboBox.

Public functions

auto checkedItems() const -> QStringList
Returns currently checked items.
auto defaultText() const -> QString
Returns default text which will be displayed in the widget when no items selected.
auto eventFilter(QObject* object, QEvent* event) -> bool override
Filters events to enable context menu.
void hidePopup() override
Hides the list of items in the combobox if it is currently visible and resets the internal state.
auto itemCheckState(int index) const -> Qt::CheckState
Returns the checked state of the item identified by index.
auto separator() const -> QString
Returns separator used to separate items in the display text.
void setDefaultText(const QString& text)
Set default text which will be displayed in the widget when no items selected.
void setItemCheckState(int index, Qt::CheckState state)
Sets the item check state to state.
void setSeparator(const QString& separator)
Set separator used to separate items in the display text.
void toggleItemCheckState(int index)
Toggles the item check state.

Signals

void checkedItemsChanged(const QStringList& items)
This signal is emitted whenever the checked items list changed.

Public slots

void setCheckedItems(const QStringList& items)
Set items which should be checked/selected.

Protected functions

void resizeEvent(QResizeEvent* event) override
Handler for widget resizing.

Protected slots

void deselectAllOptions()
Removes selection from all items.
void selectAllOptions()
Selects all items.
void showContextMenu(QPoint pos)
Display context menu which allows selecting/deselecting all items at once.

Function documentation

QStringList QgsCheckableComboBox::checkedItems() const

Returns currently checked items.

QString QgsCheckableComboBox::defaultText() const

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

Qt::CheckState QgsCheckableComboBox::itemCheckState(int index) const

Returns the checked state of the item identified by index.

Parameters
index item index

QString QgsCheckableComboBox::separator() const

Returns separator used to separate items in the display text.

void QgsCheckableComboBox::setDefaultText(const QString& text)

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

Parameters
text default text

void QgsCheckableComboBox::setItemCheckState(int index, Qt::CheckState state)

Sets the item check state to state.

Parameters
index item index
state check state

void QgsCheckableComboBox::setSeparator(const QString& separator)

Set separator used to separate items in the display text.

Parameters
separator separator to use

void QgsCheckableComboBox::toggleItemCheckState(int index)

Toggles the item check state.

Parameters
index item index

void QgsCheckableComboBox::setCheckedItems(const QStringList& items) public slot

Set items which should be checked/selected.

Parameters
items items to select