Class: QgsFilterLineEdit

class qgis.gui.QgsFilterLineEdit(parent: QWidget = None, nullValue: str = '')

Bases: PyQt5.QtWidgets.QLineEdit

Constructor for QgsFilterLineEdit.

Parameters
  • parent (QWidget = None) – parent widget

  • nullValue (str = '') – string for representing null values

QLineEdit subclass with built in support for clearing the widget’s value and handling custom null value representations.

When using QgsFilterLineEdit the value(), setValue() and clearValue() methods should be used instead of QLineEdit’s text(), setText() and clear() methods, and the valueChanged() signal should be used instead of textChanged().

Methods

actionEvent

changeEvent

childEvent

clearMode

Returns the clear mode for the widget.

clearValue

Clears the widget and resets it to the null value.

closeEvent

connectNotify

contextMenuEvent

create

cursorRect

customEvent

defaultValue

Returns the default value for the widget.

destroy

disconnectNotify

dragEnterEvent

dragLeaveEvent

dragMoveEvent

dropEvent

enterEvent

event

Reimplemented to enable/disable the clear action depending on read-only status

focusInEvent

param e

focusNextChild

focusNextPrevChild

focusOutEvent

focusPreviousChild

hideEvent

initPainter

initStyleOption

inputMethodEvent

isNull

Determine if the current text represents null.

isSignalConnected

keyPressEvent

keyReleaseEvent

leaveEvent

metric

mouseDoubleClickEvent

mouseMoveEvent

mousePressEvent

mouseReleaseEvent

param e

moveEvent

nativeEvent

nullValue

Returns the string used for representing null values in the widget.

paintEvent

receivers

resizeEvent

selectOnFocus

Will select all text when this widget receives the focus.

sender

senderSignalIndex

setClearMode

Sets the clear mode for the widget.

setDefaultValue

Sets the default value for the widget.

setNullValue

Sets the string representation for null values in the widget.

setSelectOnFocus

Will select all text when this widget receives the focus.

setShowClearButton

Sets whether the widget’s clear button is visible.

setShowSearchIcon

Define if a search icon shall be shown on the left of the image when no text is entered

setShowSpinner

Show a spinner icon.

setValue

Sets the current text for the widget with support for handling null values.

sharedPainter

showClearButton

Returns True if the widget’s clear button is visible.

showEvent

showSearchIcon

Returns if a search icon shall be shown on the left of the image when no text is entered

showSpinner

Show a spinner icon.

tabletEvent

timerEvent

updateMicroFocus

value

Returns the text of this edit with support for handling null values.

wheelEvent

Signals

cleared

Emitted when the widget is cleared

selectOnFocusChanged

Will select all text when this widget receives the focus.

showSpinnerChanged

Show a spinner icon.

valueChanged

Same as textChanged() but with support for null values.

Attributes

ClearToDefault

ClearToNull

class ClearMode

Bases: int

baseClass

alias of QgsFilterLineEdit

ClearToDefault = 1
ClearToNull = 0
actionEvent()
changeEvent()
childEvent()
clearMode(self) → QgsFilterLineEdit.ClearMode

Returns the clear mode for the widget. The clear mode defines the behavior of the widget when its value is cleared. This defaults to ClearToNull.

See also

setClearMode()

New in version 3.0.

Return type

QgsFilterLineEdit.ClearMode

clearValue(self)

Clears the widget and resets it to the null value.

See also

nullValue()

New in version 3.0.

cleared

Emitted when the widget is cleared

See also

clearValue() [signal]

closeEvent()
connectNotify()
contextMenuEvent()
create()
cursorRect()
customEvent()
defaultValue(self) → str

Returns the default value for the widget. The default value is a value which the widget will be reset to if it is cleared and the clearMode() is equal to ClearToDefault.

See also

clearMode()

New in version 3.0.

Return type

str

destroy()
disconnectNotify()
dragEnterEvent()
dragLeaveEvent()
dragMoveEvent()
dropEvent()
enterEvent()
event(self, event: QEvent) → bool

Reimplemented to enable/disable the clear action depending on read-only status

New in version 3.0.1.

Parameters

event (QEvent) –

Return type

bool

focusInEvent(self, e: QFocusEvent)
Parameters

e (QFocusEvent) –

focusNextChild()
focusNextPrevChild()
focusOutEvent()
focusPreviousChild()
hideEvent()
initPainter()
initStyleOption()
inputMethodEvent()
isNull(self) → bool

Determine if the current text represents null.

Return type

bool

Returns

True if the widget’s value is null.

See also

nullValue()

isSignalConnected()
keyPressEvent()
keyReleaseEvent()
leaveEvent()
metric()
mouseDoubleClickEvent()
mouseMoveEvent()
mousePressEvent()
mouseReleaseEvent(self, e: QMouseEvent)
Parameters

e (QMouseEvent) –

moveEvent()
nativeEvent()
nullValue(self) → str

Returns the string used for representing null values in the widget.

See also

setNullValue()

See also

isNull()

Return type

str

paintEvent()
receivers()
resizeEvent()
selectOnFocus(self) → bool

Will select all text when this widget receives the focus.

New in version 3.0.

Return type

bool

selectOnFocusChanged

Will select all text when this widget receives the focus.

New in version 3.0: [signal]

sender()
senderSignalIndex()
setClearMode(self, mode: QgsFilterLineEdit.ClearMode)

Sets the clear mode for the widget. The clear mode defines the behavior of the widget when its value is cleared. This defaults to ClearToNull.

See also

clearMode()

New in version 3.0.

Parameters

mode (QgsFilterLineEdit.ClearMode) –

setDefaultValue(self, defaultValue: str)

Sets the default value for the widget. The default value is a value which the widget will be reset to if it is cleared and the clearMode() is equal to ClearToDefault.

Parameters

defaultValue (str) – default value

See also

defaultValue()

See also

clearMode()

New in version 3.0.

setNullValue(self, nullValue: str)

Sets the string representation for null values in the widget. This does not affect the values returned for null values by value(), rather it only affects the text that is shown to users when the widget’s value is null.

Parameters

nullValue (str) – string to show when widget’s value is null

See also

nullValue()

setSelectOnFocus(self, selectOnFocus: bool)

Will select all text when this widget receives the focus.

New in version 3.0.

Parameters

selectOnFocus (bool) –

setShowClearButton(self, visible: bool)

Sets whether the widget’s clear button is visible.

Parameters

visible (bool) – set to False to hide the clear button

New in version 3.0.

setShowSearchIcon(self, visible: bool)

Define if a search icon shall be shown on the left of the image when no text is entered

Parameters

visible (bool) – set to False to hide the search icon

New in version 3.0.

setShowSpinner(self, showSpinner: bool)

Show a spinner icon. This can be used for search boxes to indicate that something is going on in the background.

New in version 3.0.

Parameters

showSpinner (bool) –

setValue(self, value: str)

Sets the current text for the widget with support for handling null values.

Parameters

value (str) – The text to set. If a null string is provided, the text shown in the widget will be set to the current nullValue().

See also

value()

sharedPainter()
showClearButton(self) → bool

Returns True if the widget’s clear button is visible.

New in version 3.0.

Return type

bool

showEvent()
showSearchIcon(self) → bool

Returns if a search icon shall be shown on the left of the image when no text is entered

New in version 3.0.

Return type

bool

showSpinner(self) → bool

Show a spinner icon. This can be used for search boxes to indicate that something is going on in the background.

New in version 3.0.

Return type

bool

showSpinnerChanged

Show a spinner icon. This can be used for search boxes to indicate that something is going on in the background.

New in version 3.0: [signal]

tabletEvent()
timerEvent()
updateMicroFocus()
value(self) → str

Returns the text of this edit with support for handling null values. If the text in the widget matches the current nullValue() then the returned value will be a null string.

Return type

str

Returns

Current text (or null string if it matches the nullValue() property )

See also

setValue()

valueChanged

Same as textChanged() but with support for null values.

Parameters

value (str) – The current text or null string if it matches the nullValue() property. [signal]

wheelEvent()