Class: QgsFilterLineEdit¶
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().
Class Hierarchy¶
Base classes¶
Subclasses¶
A line edit with an autocompleter which takes unique values from a vector layer’s fields. |
|
A |
- class qgis.gui.QgsFilterLineEdit[source]¶
Bases:
QLineEdit- __init__(parent: QWidget | None = None, nullValue: str | None = '')
Constructor for QgsFilterLineEdit.
- Parameters:
parent (Optional[QWidget] = None) – parent widget
nullValue (Optional[str] = '') – string for representing null values
- class ClearMode¶
Bases:
int
- ClearToDefault = 1¶
- ClearToNull = 0¶
- clearMode(self) QgsFilterLineEdit.ClearMode[source]¶
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
- Return type:
- signal cleared[source]¶
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.
- defaultValue(self) str[source]¶
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
See also
- Return type:
str
- virtual event(self, event: QEvent | None) bool[source]¶
Reimplemented to enable/disable the clear action depending on read-only status
- Parameters:
event (Optional[QEvent])
- Return type:
bool
- hasStateStored(self) bool[source]¶
Returns if a state is already saved
Added in version 3.14.
- Return type:
bool
- isNull(self) bool[source]¶
Determine if the current text represents null.
- Return type:
bool
- Returns:
Trueif the widget’s value is null.
See also
- nullValue(self) str[source]¶
Returns the string used for representing null values in the widget.
See also
See also
- Return type:
str
- restoreState(self)[source]¶
Restores the current state of the line edit (selection and cursor position)
Added in version 3.14.
- selectOnFocus(self) bool[source]¶
Will select all text when this widget receives the focus.
- Return type:
bool
- signal selectOnFocusChanged[source]¶
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.
- setClearMode(self, mode: QgsFilterLineEdit.ClearMode)[source]¶
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
- Parameters:
mode (QgsFilterLineEdit.ClearMode)
- setDefaultValue(self, defaultValue: str | None)[source]¶
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 (Optional[str]) – default value
See also
See also
- setNullValue(self, nullValue: str | None)[source]¶
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 (Optional[str]) – string to show when widget’s value is null
See also
- setSelectOnFocus(self, selectOnFocus: bool)[source]¶
Will select all text when this widget receives the focus.
- Parameters:
selectOnFocus (bool)
- setShowClearButton(self, visible: bool)[source]¶
Sets whether the widget’s clear button is visible.
- Parameters:
visible (bool) – set to
Falseto hide the clear button
See also
- setShowSearchIcon(self, visible: bool)[source]¶
Define if a search icon shall be shown on the left of the image when no text is entered
- Parameters:
visible (bool) – set to
Falseto hide the search icon
- setShowSpinner(self, showSpinner: bool)[source]¶
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 | None)[source]¶
Sets the current text for the widget with support for handling null values.
- Parameters:
value (Optional[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
- showClearButton(self) bool[source]¶
Returns
Trueif the widget’s clear button is visible.See also
- Return type:
bool
- showSearchIcon(self) bool[source]¶
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[source]¶
Show a spinner icon. This can be used for search boxes to indicate that something is going on in the background.
- Return type:
bool
- signal showSpinnerChanged[source]¶
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.
- storeState(self)[source]¶
Stores the current state of the line edit (selection and cursor position)
Added in version 3.14.
- value(self) str[source]¶
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
- signal valueChanged[source]¶
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.