QGIS API Documentation 3.34.0-Prizren (ffbdd678812)
Loading...
Searching...
No Matches
Public Slots | Signals | Public Member Functions | Protected Slots | Protected Member Functions | Protected Attributes | Properties | List of all members
QgsCheckableComboBox Class Reference

QComboBox subclass which allows selecting multiple items. More...

#include <qgscheckablecombobox.h>

Inheritance diagram for QgsCheckableComboBox:
Inheritance graph
[legend]

Public Slots

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

Signals

void checkedItemsChanged (const QStringList &items)
 Emitted whenever the checked items list changed.
 

Public Member Functions

 QgsCheckableComboBox (QWidget *parent=nullptr)
 Constructor for QgsCheckableComboBox.
 
void addItemWithCheckState (const QString &text, Qt::CheckState state, const QVariant &userData=QVariant())
 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).
 
QStringList checkedItems () const
 Returns currently checked items.
 
QVariantList checkedItemsData () const
 Returns userData (stored in the Qt::UserRole) associated with currently checked items.
 
QString defaultText () const
 Returns default text which will be displayed in the widget when no items selected.
 
bool eventFilter (QObject *object, QEvent *event) 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.
 
Qt::CheckState itemCheckState (int index) const
 Returns the checked state of the item identified by index.
 
QgsCheckableItemModelmodel () const
 Returns the custom item model which handles checking the items.
 
QString separator () const
 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.
 

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.
 

Protected Member Functions

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

Protected Attributes

QgsCheckableItemModelmModel = nullptr
 

Properties

QStringList checkedItems
 
QString defaultText
 
QString separator
 

Detailed Description

QComboBox subclass which allows selecting multiple items.

Since
QGIS 3.0

Definition at line 124 of file qgscheckablecombobox.h.

Constructor & Destructor Documentation

◆ QgsCheckableComboBox()

QgsCheckableComboBox::QgsCheckableComboBox ( QWidget *  parent = nullptr)

Constructor for QgsCheckableComboBox.

Definition at line 77 of file qgscheckablecombobox.cpp.

Member Function Documentation

◆ addItemWithCheckState()

void QgsCheckableComboBox::addItemWithCheckState ( const QString &  text,
Qt::CheckState  state,
const QVariant &  userData = QVariant() 
)

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.

Since
QGIS 3.16

Definition at line 138 of file qgscheckablecombobox.cpp.

◆ checkedItems()

QStringList QgsCheckableComboBox::checkedItems ( ) const

Returns currently checked items.

See also
setCheckedItems()

Definition at line 144 of file qgscheckablecombobox.cpp.

◆ checkedItemsChanged

void QgsCheckableComboBox::checkedItemsChanged ( const QStringList &  items)
signal

Emitted whenever the checked items list changed.

◆ checkedItemsData()

QVariantList QgsCheckableComboBox::checkedItemsData ( ) const

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

See also
checkedItems()

Definition at line 162 of file qgscheckablecombobox.cpp.

◆ defaultText()

QString QgsCheckableComboBox::defaultText ( ) const

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

See also
setDefaultText()

Definition at line 124 of file qgscheckablecombobox.cpp.

◆ deselectAllOptions

void QgsCheckableComboBox::deselectAllOptions ( )
protectedslot

Removes selection from all items.

Definition at line 228 of file qgscheckablecombobox.cpp.

◆ eventFilter()

bool QgsCheckableComboBox::eventFilter ( QObject *  object,
QEvent *  event 
)
override

Filters events to enable context menu.

Definition at line 239 of file qgscheckablecombobox.cpp.

◆ hidePopup()

void QgsCheckableComboBox::hidePopup ( )
override

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

Definition at line 201 of file qgscheckablecombobox.cpp.

◆ itemCheckState()

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

Returns the checked state of the item identified by index.

Parameters
indexitem index
See also
setItemCheckState()
toggleItemCheckState()

Definition at line 180 of file qgscheckablecombobox.cpp.

◆ model()

QgsCheckableItemModel * QgsCheckableComboBox::model ( ) const
inline

Returns the custom item model which handles checking the items.

See also
QgsCheckableItemModel
Since
QGIS 3.16

Definition at line 218 of file qgscheckablecombobox.h.

◆ resizeEvent()

void QgsCheckableComboBox::resizeEvent ( QResizeEvent *  event)
overrideprotected

Handler for widget resizing.

Definition at line 287 of file qgscheckablecombobox.cpp.

◆ selectAllOptions

void QgsCheckableComboBox::selectAllOptions ( )
protectedslot

Selects all items.

Definition at line 217 of file qgscheckablecombobox.cpp.

◆ separator()

QString QgsCheckableComboBox::separator ( ) const

Returns separator used to separate items in the display text.

See also
setSeparator()

Definition at line 110 of file qgscheckablecombobox.cpp.

◆ setCheckedItems

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

Set items which should be checked/selected.

Parameters
itemsitems to select
See also
checkedItems()

Definition at line 276 of file qgscheckablecombobox.cpp.

◆ setDefaultText()

void QgsCheckableComboBox::setDefaultText ( const QString &  text)

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

Parameters
textdefault text
See also
defaultText()

Definition at line 129 of file qgscheckablecombobox.cpp.

◆ setItemCheckState()

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

Sets the item check state to state.

Parameters
indexitem index
statecheck state
See also
itemCheckState()
toggleItemCheckState()

Definition at line 185 of file qgscheckablecombobox.cpp.

◆ setSeparator()

void QgsCheckableComboBox::setSeparator ( const QString &  separator)

Set separator used to separate items in the display text.

Parameters
separatorseparator to use
See also
separator()

Definition at line 115 of file qgscheckablecombobox.cpp.

◆ showContextMenu

void QgsCheckableComboBox::showContextMenu ( QPoint  pos)
protectedslot

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

Definition at line 210 of file qgscheckablecombobox.cpp.

◆ toggleItemCheckState()

void QgsCheckableComboBox::toggleItemCheckState ( int  index)

Toggles the item check state.

Parameters
indexitem index
See also
itemCheckState()
setItemCheckState()

Definition at line 190 of file qgscheckablecombobox.cpp.

Member Data Documentation

◆ mModel

QgsCheckableItemModel* QgsCheckableComboBox::mModel = nullptr
protected

Definition at line 273 of file qgscheckablecombobox.h.

Property Documentation

◆ checkedItems

QStringList QgsCheckableComboBox::checkedItems
readwrite

Definition at line 130 of file qgscheckablecombobox.h.

◆ defaultText

QString QgsCheckableComboBox::defaultText
readwrite

Definition at line 129 of file qgscheckablecombobox.h.

◆ separator

QString QgsCheckableComboBox::separator
readwrite

Definition at line 128 of file qgscheckablecombobox.h.


The documentation for this class was generated from the following files: