Class: QgsFilterLineEdit

class qgis.gui.QgsFilterLineEdit

Bases: PyQt5.QtWidgets.QLineEdit

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().

QgsFilterLineEdit(parent: QWidget = None, nullValue: str = ‘’) Constructor for QgsFilterLineEdit.

Parameters:
class ClearMode

Bases: int

baseClass

alias of QgsFilterLineEdit

ClearToDefault = 1
ClearToNull = 0
actionEvent(self, QActionEvent)
changeEvent(self, QEvent)
childEvent(self, QChildEvent)
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()

Return type:

QgsFilterLineEdit.ClearMode

clearValue(self)

Clears the widget and resets it to the null value.

See also

nullValue()

cleared

pyqtSignal(*types, name: str = …, revision: int = …, arguments: Sequence = …) -> PYQT_SIGNAL

types is normally a sequence of individual types. Each type is either a type object or a string that is the name of a C++ type. Alternatively each type could itself be a sequence of types each describing a different overloaded signal. name is the optional C++ name of the signal. If it is not specified then the name of the class attribute that is bound to the signal is used. revision is the optional revision of the signal that is exported to QML. If it is not specified then 0 is used. arguments is the optional sequence of the names of the signal’s arguments.

Parameters:
  • name (str = ...) –

  • revision (int = ...) –

  • arguments (Sequence = ...) –

Return type:

PYQT_SIGNAL

closeEvent(self, QCloseEvent)
connectNotify(self, QMetaMethod)
contextMenuEvent(self, QContextMenuEvent)
create(self, window: PyQt5.sip.voidptr = 0, initializeWindow: bool = True, destroyOldWindow: bool = True)
cursorRect(self) QRect
customEvent(self, QEvent)
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()

Return type:

str

destroy(self, destroyWindow: bool = True, destroySubWindows: bool = True)
disconnectNotify(self, QMetaMethod)
dragEnterEvent(self, QDragEnterEvent)
dragLeaveEvent(self, QDragLeaveEvent)
dragMoveEvent(self, QDragMoveEvent)
dropEvent(self, QDropEvent)
enterEvent(self, QEvent)
event(self, event: QEvent) bool

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

Parameters:

event (QEvent) –

Return type:

bool

focusInEvent(self, e: QFocusEvent)
Parameters:

e (QFocusEvent) –

focusNextChild(self) bool
focusNextPrevChild(self, bool) bool
focusOutEvent(self, QFocusEvent)
focusPreviousChild(self) bool
hasStateStored(self) bool

Returns if a state is already saved

New in version 3.14.

Return type:

bool

hideEvent(self, QHideEvent)
initPainter(self, QPainter)
initStyleOption(self, QStyleOptionFrame)
inputMethodEvent(self, QInputMethodEvent)
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(self, QMetaMethod) bool
keyPressEvent(self, QKeyEvent)
keyReleaseEvent(self, QKeyEvent)
leaveEvent(self, QEvent)
metric(self, QPaintDevice.PaintDeviceMetric) int
mouseDoubleClickEvent(self, QMouseEvent)
mouseMoveEvent(self, QMouseEvent)
mousePressEvent(self, QMouseEvent)
mouseReleaseEvent(self, e: QMouseEvent)
Parameters:

e (QMouseEvent) –

moveEvent(self, QMoveEvent)
nativeEvent(self, Union[QByteArray, bytes, bytearray], PyQt5.sip.voidptr) Tuple[bool, int]
nullValue(self) str

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

See also

setNullValue()

See also

isNull()

Return type:

str

paintEvent(self, QPaintEvent)
receivers(self, PYQT_SIGNAL) int
resizeEvent(self, QResizeEvent)
restoreState(self)

Restores the current state of the line edit (selection and cursor position)

New in version 3.14.

selectOnFocus(self) bool

Will select all text when this widget receives the focus.

Return type:

bool

selectOnFocusChanged

pyqtSignal(*types, name: str = …, revision: int = …, arguments: Sequence = …) -> PYQT_SIGNAL

types is normally a sequence of individual types. Each type is either a type object or a string that is the name of a C++ type. Alternatively each type could itself be a sequence of types each describing a different overloaded signal. name is the optional C++ name of the signal. If it is not specified then the name of the class attribute that is bound to the signal is used. revision is the optional revision of the signal that is exported to QML. If it is not specified then 0 is used. arguments is the optional sequence of the names of the signal’s arguments.

Parameters:
  • name (str = ...) –

  • revision (int = ...) –

  • arguments (Sequence = ...) –

Return type:

PYQT_SIGNAL

sender(self) QObject
senderSignalIndex(self) int
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()

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()

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.

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

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

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.

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(self) QPainter
showClearButton(self) bool

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

Return type:

bool

showEvent(self, QShowEvent)
showSearchIcon(self) bool

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

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.

Return type:

bool

showSpinnerChanged

pyqtSignal(*types, name: str = …, revision: int = …, arguments: Sequence = …) -> PYQT_SIGNAL

types is normally a sequence of individual types. Each type is either a type object or a string that is the name of a C++ type. Alternatively each type could itself be a sequence of types each describing a different overloaded signal. name is the optional C++ name of the signal. If it is not specified then the name of the class attribute that is bound to the signal is used. revision is the optional revision of the signal that is exported to QML. If it is not specified then 0 is used. arguments is the optional sequence of the names of the signal’s arguments.

Parameters:
  • name (str = ...) –

  • revision (int = ...) –

  • arguments (Sequence = ...) –

Return type:

PYQT_SIGNAL

storeState(self)

Stores the current state of the line edit (selection and cursor position)

New in version 3.14.

tabletEvent(self, QTabletEvent)
timerEvent(self, QTimerEvent)
updateMicroFocus(self)
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

pyqtSignal(*types, name: str = …, revision: int = …, arguments: Sequence = …) -> PYQT_SIGNAL

types is normally a sequence of individual types. Each type is either a type object or a string that is the name of a C++ type. Alternatively each type could itself be a sequence of types each describing a different overloaded signal. name is the optional C++ name of the signal. If it is not specified then the name of the class attribute that is bound to the signal is used. revision is the optional revision of the signal that is exported to QML. If it is not specified then 0 is used. arguments is the optional sequence of the names of the signal’s arguments.

Parameters:
  • name (str = ...) –

  • revision (int = ...) –

  • arguments (Sequence = ...) –

Return type:

PYQT_SIGNAL

wheelEvent(self, QWheelEvent)