Class: QgsSearchWidgetWrapper

class qgis.gui.QgsSearchWidgetWrapper(vl: QgsVectorLayer, fieldIdx: int, parent: QWidget = None)

Bases: QgsWidgetWrapper

Create a new widget wrapper

Parameters
  • vl (QgsVectorLayer) – The layer on which the field is

  • fieldIdx (int) – The field which will be controlled

  • parent (QWidget = None) – A parent widget for this widget wrapper and the created widget.

Shows a search widget on a filter form.

Methods

aggregate

If in AggregateSearch mode, which aggregate should be used to construct the filter expression.

applyDirectly

If this is True, then this search widget should take effect directly when its expression changes

childEvent

clearExpression

clears the expression to search for all features

clearWidget

Clears the widget’s current value and resets it back to the default state

connectNotify

createExpression

param flags

createFieldIdentifier

Gets a field name or expression to use as field comparison.

createWidget

customEvent

defaultFlags

Returns the filter flags which should be set by default for the search widget.

disconnectNotify

exclusiveFilterFlags

Returns a list of exclusive filter flags, which cannot be combined with other flags (e.g., EqualTo/NotEqualTo)

expression

Will be used to access the widget’s value.

fieldIndex

Returns the field index

initWidget

isSignalConnected

nonExclusiveFilterFlags

Returns a list of non-exclusive filter flags, which can be combined with other flags (e.g., CaseInsensitive)

receivers

sender

senderSignalIndex

setAggregate

If in AggregateSearch mode, which aggregate should be used to construct the filter expression.

setEnabled

Toggles whether the search widget is enabled or disabled.

setExpression

Set the expression which is currently used as filter for this widget.

setFeature

param feature

supportedFlags

Returns filter flags supported by the search widget.

timerEvent

toString

Returns a translated string representing a filter flag.

Signals

expressionChanged

Emitted whenever the expression changes

valueChanged

Emitted when a user changes the value of the search widget.

valueCleared

Emitted when a user changes the value of the search widget back to an empty, default state.

Attributes

Between

CaseInsensitive

Contains

DoesNotContain

EndsWith

EqualTo

GreaterThan

GreaterThanOrEqualTo

IsNotBetween

IsNotNull

IsNull

LessThan

LessThanOrEqualTo

NotEqualTo

StartsWith

Between = 128
CaseInsensitive = 256
Contains = 512
DoesNotContain = 1024
EndsWith = 32768
EqualTo = 2
class FilterFlag

Bases: int

class FilterFlags

Bases: sip.wrapper

QgsSearchWidgetWrapper.FilterFlags(Union[QgsSearchWidgetWrapper.FilterFlags, QgsSearchWidgetWrapper.FilterFlag]) QgsSearchWidgetWrapper.FilterFlags(QgsSearchWidgetWrapper.FilterFlags)

GreaterThan = 8
GreaterThanOrEqualTo = 32
IsNotBetween = 4096
IsNotNull = 8192
IsNull = 2048
LessThan = 16
LessThanOrEqualTo = 64
NotEqualTo = 4
StartsWith = 16384
aggregate(self) → str

If in AggregateSearch mode, which aggregate should be used to construct the filter expression. Is a Null String if none.

New in version 3.0.

Return type

str

applyDirectly(self) → bool

If this is True, then this search widget should take effect directly when its expression changes

Return type

bool

childEvent()
clearExpression(self)

clears the expression to search for all features

clearWidget(self)

Clears the widget’s current value and resets it back to the default state

New in version 2.16.

connectNotify()
createExpression(self, flags: Union[QgsSearchWidgetWrapper.FilterFlags, QgsSearchWidgetWrapper.FilterFlag]) → str
Parameters

flags (Union[QgsSearchWidgetWrapper.FilterFlags) –

Return type

str

createFieldIdentifier(self) → str

Gets a field name or expression to use as field comparison. If in SearchMode returns a quoted field identifier. If in AggregateSearchMode returns an appropriate aggregate expression.

New in version 3.0.

Return type

str

createWidget()
customEvent()
defaultFlags(self) → QgsSearchWidgetWrapper.FilterFlags

Returns the filter flags which should be set by default for the search widget.

See also

supportedFlags()

New in version 2.16.

Return type

QgsSearchWidgetWrapper.FilterFlags

disconnectNotify()
exclusiveFilterFlags() → object

Returns a list of exclusive filter flags, which cannot be combined with other flags (e.g., EqualTo/NotEqualTo)

New in version 2.16.

Return type

object

expression(self) → str

Will be used to access the widget’s value. Read the value from the widget and return it properly formatted to be saved in the attribute.

If an invalid variant is returned this will be interpreted as no change. Be sure to return a NULL QVariant if it should be set to NULL.

Return type

str

Returns

The current value the widget represents

expressionChanged

Emitted whenever the expression changes

Parameters

exp (str) – The new search expression [signal]

fieldIndex(self) → int

Returns the field index

New in version 3.10.

Return type

int

initWidget()
isSignalConnected()
nonExclusiveFilterFlags() → object

Returns a list of non-exclusive filter flags, which can be combined with other flags (e.g., CaseInsensitive)

New in version 2.16.

Return type

object

receivers()
sender()
senderSignalIndex()
setAggregate(self, aggregate: str)

If in AggregateSearch mode, which aggregate should be used to construct the filter expression. Is a Null String if none.

New in version 3.0.

Parameters

aggregate (str) –

setEnabled(self, enabled: bool)

Toggles whether the search widget is enabled or disabled.

Parameters

enabled (bool) – set to True to enable widget

setExpression(self, expression: str)

Set the expression which is currently used as filter for this widget.

Parameters

expression (str) –

setFeature(self, feature: QgsFeature)
Parameters

feature (QgsFeature) –

supportedFlags(self) → QgsSearchWidgetWrapper.FilterFlags

Returns filter flags supported by the search widget.

See also

defaultFlags()

New in version 2.16.

Return type

QgsSearchWidgetWrapper.FilterFlags

timerEvent()
toString(flag: QgsSearchWidgetWrapper.FilterFlag) → str

Returns a translated string representing a filter flag.

Parameters

flag (QgsSearchWidgetWrapper.FilterFlag) – flag to convert to string

New in version 2.16.

Return type

str

valueChanged

Emitted when a user changes the value of the search widget.

New in version 2.16: [signal]

valueCleared

Emitted when a user changes the value of the search widget back to an empty, default state.

New in version 2.16: [signal]