Skip to content

Commit 713192f

Browse files
committed
set value to null when pressed lineedit-clearbutton
1 parent 13d2586 commit 713192f

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

src/gui/qgsfeaturelistcombobox.cpp

+7
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ QgsFeatureListComboBox::QgsFeatureListComboBox( QWidget *parent )
5454

5555
mLineEdit = new QgsFilterLineEdit();
5656
mLineEdit->setSelectOnFocus( true );
57+
connect( mLineEdit, &QgsFilterLineEdit::cleared, this, &QgsFeatureListComboBox::setValueToNull );
5758
setEditable( true );
5859
setLineEdit( mLineEdit );
5960
setModel( mModel );
@@ -249,3 +250,9 @@ void QgsFeatureListComboBox::LineEditState::restore( QLineEdit *lineEdit ) const
249250
if ( selectionStart > -1 )
250251
lineEdit->setSelection( selectionStart, selectionLength );
251252
}
253+
254+
void QgsFeatureListComboBox::setValueToNull()
255+
{
256+
if ( allowNull() )
257+
setCurrentIndex( nullIndex() );
258+
}

src/gui/qgsfeaturelistcombobox.h

+1
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,7 @@ class GUI_EXPORT QgsFeatureListComboBox : public QComboBox
200200
void storeLineEditState();
201201
void restoreLineEditState();
202202
void onDataChanged( const QModelIndex &topLeft, const QModelIndex &bottomRight, const QVector<int> &roles = QVector<int>() );
203+
void setValueToNull();
203204

204205
private:
205206
struct LineEditState

0 commit comments

Comments
 (0)