Skip to content
Permalink
Browse files

create helper method QgsCheckableComboBox::addItemWithCheckState

  • Loading branch information
3nids committed Sep 14, 2020
1 parent 4fe3d2f commit b516a49b9e8856567997c1f941dec8d69a749653
@@ -62,6 +62,15 @@ no items selected.
:param text: default text

.. seealso:: :py:func:`defaultText`
%End

void addItemWithCheckState( const QString &text, Qt::CheckState state, const QVariant &userData = QVariant() );
%Docstring
Adds an item to the combobox with the given ``text``, check ``state``
and containing the specified ``userData`` (stored in the Qt.UserRole).
The item is appended to the list of existing items.

.. versionadded:: 3.16
%End

QStringList checkedItems() const;
@@ -134,6 +134,12 @@ void QgsCheckableComboBox::setDefaultText( const QString &text )
}
}

void QgsCheckableComboBox::addItemWithCheckState( const QString &text, Qt::CheckState state, const QVariant &userData )
{
QComboBox::addItem( text, userData );
setItemCheckState( count(), state );
}

QStringList QgsCheckableComboBox::checkedItems() const
{
QStringList items;
@@ -163,6 +163,14 @@ class GUI_EXPORT QgsCheckableComboBox : public QComboBox
*/
void setDefaultText( const QString &text );

/**
* Adds an item to the combobox with the given \a text, check \a state
* and containing the specified \a userData (stored in the Qt::UserRole).
* The item is appended to the list of existing items.
* \since QGIS 3.16
*/
void addItemWithCheckState( const QString &text, Qt::CheckState state, const QVariant &userData = QVariant() );

/**
* Returns currently checked items.
* \see setCheckedItems()

0 comments on commit b516a49

Please sign in to comment.
You can’t perform that action at this time.