Skip to content

Commit a02fb08

Browse files
committed
Remove the null representator text on getting focus of QgsSpinBoxLineEdit
This fixes #20153
1 parent 6da99a1 commit a02fb08

File tree

2 files changed

+27
-0
lines changed

2 files changed

+27
-0
lines changed

src/gui/qgsfilterlineedit.cpp

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -212,3 +212,22 @@ bool QgsFilterLineEdit::event( QEvent *event )
212212

213213
return QLineEdit::event( event );;
214214
}
215+
216+
void QgsSpinBoxLineEdit::focusInEvent( QFocusEvent *e )
217+
{
218+
QLineEdit::focusInEvent( e );
219+
if ( e->reason() == Qt::MouseFocusReason && ( isNull() ) )
220+
{
221+
mWaitingForMouseRelease = true;
222+
}
223+
}
224+
225+
void QgsSpinBoxLineEdit::mouseReleaseEvent( QMouseEvent *e )
226+
{
227+
QLineEdit::mouseReleaseEvent( e );
228+
if ( mWaitingForMouseRelease )
229+
{
230+
mWaitingForMouseRelease = false;
231+
clear();
232+
}
233+
}

src/gui/qgsfilterlineedit.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -324,6 +324,14 @@ class SIP_SKIP QgsSpinBoxLineEdit : public QgsFilterLineEdit
324324
setModified( true );
325325
emit cleared();
326326
}
327+
328+
protected:
329+
void focusInEvent( QFocusEvent *e ) override;
330+
void mouseReleaseEvent( QMouseEvent *e ) override;
331+
332+
private:
333+
bool mWaitingForMouseRelease = false;
334+
327335
};
328336
/// @endcond
329337

0 commit comments

Comments
 (0)