Skip to content

Commit cc0c1bc

Browse files
committed
[QgsFilterLineEdit] disable clear action when read only
1 parent e1ad1cb commit cc0c1bc

File tree

3 files changed

+26
-0
lines changed

3 files changed

+26
-0
lines changed

python/gui/qgsfilterlineedit.sip.in

+9
Original file line numberDiff line numberDiff line change
@@ -213,6 +213,15 @@ Will select all text when this widget receives the focus.
213213
.. versionadded:: 3.0
214214
%End
215215

216+
217+
virtual bool event( QEvent *event );
218+
%Docstring
219+
Reimplemented to enable/disable the clear action
220+
depending on read-only status
221+
222+
.. versionadded:: 3.0.1
223+
%End
224+
216225
public slots:
217226

218227
virtual void clearValue();

src/gui/qgsfilterlineedit.cpp

+8
Original file line numberDiff line numberDiff line change
@@ -178,3 +178,11 @@ bool QgsFilterLineEdit::shouldShowClear() const
178178
}
179179
return false; //avoid warnings
180180
}
181+
182+
bool QgsFilterLineEdit::event( QEvent *event )
183+
{
184+
if ( event->type() == QEvent::ReadOnlyChange )
185+
updateClearIcon();
186+
187+
return QLineEdit::event( event );;
188+
}

src/gui/qgsfilterlineedit.h

+9
Original file line numberDiff line numberDiff line change
@@ -213,6 +213,15 @@ class GUI_EXPORT QgsFilterLineEdit : public QLineEdit
213213
*/
214214
void setSelectOnFocus( bool selectOnFocus );
215215

216+
217+
/**
218+
* Reimplemented to enable/disable the clear action
219+
* depending on read-only status
220+
*
221+
* \since QGIS 3.0.1
222+
*/
223+
virtual bool event( QEvent *event ) override;
224+
216225
public slots:
217226

218227
/**

0 commit comments

Comments
 (0)