Skip to content

Commit

Permalink
set value to null when pressed lineedit-clearbutton
Browse files Browse the repository at this point in the history
cherry-picked from 713192f
  • Loading branch information
signedav committed Oct 30, 2018
1 parent 3ffdae1 commit 1276671
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/gui/qgsfeaturelistcombobox.cpp
Expand Up @@ -54,6 +54,7 @@ QgsFeatureListComboBox::QgsFeatureListComboBox( QWidget *parent )

mLineEdit = new QgsFilterLineEdit();
mLineEdit->setSelectOnFocus( true );
connect( mLineEdit, &QgsFilterLineEdit::cleared, this, &QgsFeatureListComboBox::setValueToNull );
setEditable( true );
setLineEdit( mLineEdit );
setModel( mModel );
Expand Down Expand Up @@ -249,3 +250,9 @@ void QgsFeatureListComboBox::LineEditState::restore( QLineEdit *lineEdit ) const
if ( selectionStart > -1 )
lineEdit->setSelection( selectionStart, selectionLength );
}

void QgsFeatureListComboBox::setValueToNull()
{
if ( allowNull() )
setCurrentIndex( nullIndex() );
}
1 change: 1 addition & 0 deletions src/gui/qgsfeaturelistcombobox.h
Expand Up @@ -200,6 +200,7 @@ class GUI_EXPORT QgsFeatureListComboBox : public QComboBox
void storeLineEditState();
void restoreLineEditState();
void onDataChanged( const QModelIndex &topLeft, const QModelIndex &bottomRight, const QVector<int> &roles = QVector<int>() );
void setValueToNull();

private:
struct LineEditState
Expand Down

0 comments on commit 1276671

Please sign in to comment.