Subgroup: Editor
Class: QgsEditorWidgetWrapper¶
-
class
qgis.gui.
QgsEditorWidgetWrapper
¶ Bases:
qgis._gui.QgsWidgetWrapper
Manages an editor widget Widget and wrapper share the same parent
A wrapper controls one attribute editor widget and is able to create a default widget or use a pre-existent widget. It is able to set the widget to the value implied by a field of a vector layer, or return the value it currently holds. Every time it is changed it has to emit a valueChanged signal. If it fails to do so, there is no guarantee that the changed status of the widget will be saved.
Methods
blockSignals
childEvent
children
config
Use this inside your overridden classes to access the configuration. connectNotify
constraintFailureReason
Returns the reason why a constraint check has failed (or an empty string if constraint check was successful). constraintResult
Getter of constraintResult It’s the current result of the constraint on the widget influencing it’s visualization. constraintResultVisible
Getter of constraintResultVisible Defines if the constraint result should be visualized on the widget (with color). context
Returns information about the context in which this widget is shown createWidget
customEvent
dataDefinedProperties
Returns a reference to the editor widget’s property collection, used for data defined overrides. defaultValue
Access the default value of the field. deleteLater
disconnect
disconnectNotify
dumpObjectInfo
dumpObjectTree
dynamicPropertyNames
emitValueChanged
Will call the value() method to determine the emitted value event
eventFilter
field
Access the field. fieldIdx
Access the field index. findChild
findChild(self, Tuple, name: str = ‘’, options: Union[Qt.FindChildOptions, Qt.FindChildOption] = Qt.FindChildrenRecursively) -> QObject findChildren
findChildren(self, Tuple, name: str = ‘’, options: Union[Qt.FindChildOptions, Qt.FindChildOption] = Qt.FindChildrenRecursively) -> List[QObject] fromWidget
Will return a wrapper for a given widget inherits
initWidget
installEventFilter
isBlockingCommit
Returns true if the widget is preventing the feature from being committed. isInTable
Check if the given widget or one of its parent is a QTableView. isSignalConnected
isValidConstraint
Get the current constraint status. isWidgetType
isWindowType
killTimer
layer
Access the QgsVectorLayer
, you are working onmetaObject
moveToThread
objectName
parent
property
propertyDefinitions
Returns the editor widget property definitions. pyqtConfigure
Each keyword argument is either the name of a Qt property or a Qt signal. receivers
removeEventFilter
sender
senderSignalIndex
setConfig
Will set the config of this wrapper to the specified config. setConstraintResultVisible
Setter of constraintResultVisible Defines if the constraint result should be visualized on the widget (with color). setContext
Set the context in which this widget is shown setDataDefinedProperties
Sets the editor widget’s property collection, used for data defined overrides. setEnabled
Is used to enable or disable the edit functionality of the managed widget. setFeature
Will be called when the feature changes setHint
Add a hint text on the widget setObjectName
setParent
setProperty
setValue
Is called, when the value of the widget needs to be changed. showIndeterminateState
Sets the widget to display in an indeterminate “mixed value” state. signalsBlocked
startTimer
thread
timerEvent
tr
updateConstraint
Update constraint. updateConstraintWidgetStatus
This should update the widget with a visual cue if a constraint status changed. valid
Return true if the widget has been properly initialized. value
Will be used to access the widget’s value. widget
Access the widget managed by this wrapper Attributes
ConstraintResultFailHard
ConstraintResultFailSoft
ConstraintResultPass
DocumentViewerContent
RootPath
constraintResultVisibleChanged
Emit this signal when the constraint result visibility changed. constraintStatusChanged
Emit this signal when the constraint status changed. destroyed
destroyed(self, QObject = None) [signal] objectNameChanged
objectNameChanged(self, str) [signal] staticMetaObject
valueChanged
Emit this signal, whenever the value changed. -
class
ConstraintResult
¶ Bases:
int
-
ConstraintResultFailHard
= 1¶
-
ConstraintResultFailSoft
= 2¶
-
ConstraintResultPass
= 0¶
-
childEvent
()¶
-
connectNotify
()¶
-
constraintFailureReason
(self) → str¶ Returns the reason why a constraint check has failed (or an empty string if constraint check was successful).
See also
New in version 3.0.
-
constraintResult
(self) → QgsEditorWidgetWrapper.ConstraintResult¶ Getter of constraintResult It’s the current result of the constraint on the widget influencing it’s visualization.
New in version 3.0.
-
constraintResultVisible
(self) → bool¶ Getter of constraintResultVisible Defines if the constraint result should be visualized on the widget (with color). This will be disabled when the form is not editable.
New in version 3.0.
-
constraintResultVisibleChanged
¶ Emit this signal when the constraint result visibility changed. [signal]
-
constraintStatusChanged
¶ - Emit this signal when the constraint status changed.
- constraintStatusChanged
Parameters: - constraint – represented as a string
- desc – is the constraint description
- err – the error represented as a string. Empty if none.
- status – [signal]
-
createWidget
()¶
-
customEvent
()¶
-
defaultValue
(self) → Any¶ Access the default value of the field.
Returns: the default value of the field See also
layer()
-
disconnectNotify
()¶
-
emitValueChanged
(self)¶ Will call the value() method to determine the emitted value
-
field
(self) → QgsField¶ Access the field.
Returns: The field you are working on See also
layer()
-
fieldIdx
(self) → int¶ Access the field index.
Returns: The index of the field you are working on See also
layer()
-
fromWidget
(widget: QWidget) → QgsEditorWidgetWrapper¶ Will return a wrapper for a given widget
Parameters: widget – The widget which was created by a wrapper Returns: The wrapper for the widget or NULL
-
initWidget
()¶
-
isBlockingCommit
(self) → bool¶ Returns true if the widget is preventing the feature from being committed. This may be true as a result of attribute values failing enforced field constraints.
New in version 3.0.
See also
-
isInTable
(parent: QWidget) → bool¶ Check if the given widget or one of its parent is a QTableView.
Parameters: parent – the widget to check Returns: true if yes
-
isSignalConnected
()¶
-
isValidConstraint
(self) → bool¶ Get the current constraint status.
Returns: true if the constraint is valid or if there’s no constraint, false otherwise
New in version 2.16.
See also
See also
-
receivers
()¶
-
sender
()¶
-
senderSignalIndex
()¶
-
setConstraintResultVisible
(self, constraintResultVisible: bool)¶ Setter of constraintResultVisible Defines if the constraint result should be visualized on the widget (with color). This will be disabled when the form is not editable.
Parameters: constraintResultVisible – if constraintResult should be displayed (mostly editable status) New in version 3.0.
-
setEnabled
(self, enabled: bool)¶ Is used to enable or disable the edit functionality of the managed widget. By default this will enable or disable the whole widget
Parameters: enabled – Enable or Disable?
-
setFeature
(self, feature: QgsFeature)¶ Will be called when the feature changes
Is forwarded to the slot setValue()
Parameters: feature – The new feature
-
setHint
(self, hintText: str)¶ Add a hint text on the widget
Parameters: hintText – The hint text to display New in version 3.0.
-
setValue
(self, value: Any)¶ Is called, when the value of the widget needs to be changed. Update the widget representation to reflect the new value.
Parameters: value – The new value of the attribute
-
showIndeterminateState
(self)¶ Sets the widget to display in an indeterminate “mixed value” state.
New in version 2.16.
-
timerEvent
()¶
-
updateConstraint
(self, featureContext: QgsFeature, constraintOrigin: QgsFieldConstraints.ConstraintOrigin = QgsFieldConstraints.ConstraintOriginNotSet)¶ Update constraint.
Parameters: - featureContext – the feature to use to evaluate the constraint
- constraintOrigin – optional origin for constraints to check. This can be used to limit the constraints tested
to only provider or layer based constraints.
New in version 2.16.
updateConstraint(self, layer: QgsVectorLayer, index: int, feature: QgsFeature, constraintOrigin: QgsFieldConstraints.ConstraintOrigin = QgsFieldConstraints.ConstraintOriginNotSet) Update constraint on a feature coming from a specific layer.
Parameters: - layer – The vector layer where the feature is defined
- index – The index of the field to check
- feature – The feature to use to evaluate the constraint
- constraintOrigin – Optional origin for constraints to check. This
can be used to limit the constraints tested to only provider or layer based constraints.
New in version 3.0.
-
updateConstraintWidgetStatus
(self)¶ This should update the widget with a visual cue if a constraint status changed.
By default a stylesheet will be applied on the widget that changes the background color to red.
This can be overwritten in subclasses to allow individual widgets to change the visual cue.
New in version 2.16.
-
value
(self) → Any¶ 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.
Returns: The current value the widget represents
-
valueChanged
¶ Emit this signal, whenever the value changed.
Parameters: value – The new value [signal]
-
class