Subgroup: Field
Class: QgsFieldExpressionWidget¶
-
class
qgis.gui.
QgsFieldExpressionWidget
¶ Bases:
PyQt5.QtWidgets.QWidget
The QgsFieldExpressionWidget class reates a widget to choose fields and edit expressions It contains a combo boxto display the fields and expression and a button to open the expression dialog. The combo box is editable, allowing expressions to be edited inline. The validity of the expression is checked live on key press, invalid expressions are displayed in red. The expression will be added to the model (and the fieldChanged signals emitted) only when editing in the line edit is finished (focus lost, enter key pressed).
Methods
acceptDrops
accessibleDescription
accessibleName
actionEvent
actions
activateWindow
addAction
addActions
adjustSize
allowEvalErrors
Allow accepting expressions with evaluation errors. asExpression
Returns the currently selected field or expression. autoFillBackground
backgroundRole
baseSize
blockSignals
changeEvent
childAt
childAt(self, int, int) -> QWidget childEvent
children
childrenRect
childrenRegion
clearFocus
clearMask
close
closeEvent
colorCount
connectNotify
contentsMargins
contentsRect
contextMenuEvent
contextMenuPolicy
create
createWindowContainer
currentField
currentField returns the currently selected field or expression if allowed currentFieldChanged
currentText
Return the current text that is set in the expression area cursor
customEvent
deleteLater
depth
destroy
devType
devicePixelRatio
devicePixelRatioF
devicePixelRatioFScale
disconnect
disconnectNotify
dragEnterEvent
dragLeaveEvent
dragMoveEvent
dropEvent
dumpObjectInfo
dumpObjectTree
dynamicPropertyNames
editExpression
open the expression dialog to edit the current or add a new expression effectiveWinId
ensurePolished
enterEvent
event
eventFilter
expression
Returns the currently selected field or expression. expressionDialogTitle
return the title used for the expression dialog expressionEdited
when expression is edited by the user in the line edit, it will be checked for validity expressionEditingFinished
when expression has been edited (finished) it will be added to the model filters
currently used filter on list of fields find
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] focusInEvent
focusNextChild
focusNextPrevChild
focusOutEvent
focusPolicy
focusPreviousChild
focusProxy
focusWidget
font
fontInfo
fontMetrics
foregroundRole
frameGeometry
frameSize
geometry
getContentsMargins
grab
grabGesture
grabKeyboard
grabMouse
grabMouse(self, Union[QCursor, Qt.CursorShape]) grabShortcut
graphicsEffect
graphicsProxyWidget
hasFocus
hasHeightForWidth
hasMouseTracking
hasTabletTracking
height
heightForWidth
heightMM
hide
hideEvent
inherits
initPainter
inputMethodEvent
inputMethodHints
inputMethodQuery
insertAction
insertActions
installEventFilter
isActiveWindow
isAncestorOf
isEnabled
isEnabledTo
isExpression
If the content is not just a simple field this method will return true. isExpressionValid
isFullScreen
isHidden
isLeftToRight
isMaximized
isMinimized
isModal
isRightToLeft
isSignalConnected
isValidExpression
Return true if the current expression is valid isVisible
isVisibleTo
isWidgetType
isWindow
isWindowModified
isWindowType
keyPressEvent
keyReleaseEvent
keyboardGrabber
killTimer
layer
Returns the layer currently associated with the widget. layout
layoutDirection
leaveEvent
locale
logicalDpiX
logicalDpiY
lower
mapFrom
mapFromGlobal
mapFromParent
mapTo
mapToGlobal
mapToParent
mask
maximumHeight
maximumSize
maximumWidth
metaObject
metric
minimumHeight
minimumSize
minimumSizeHint
minimumWidth
mouseDoubleClickEvent
mouseGrabber
mouseMoveEvent
mousePressEvent
mouseReleaseEvent
move
move(self, int, int) moveEvent
moveToThread
nativeEvent
nativeParentWidget
nextInFocusChain
normalGeometry
objectName
overrideWindowFlags
overrideWindowState
paintEngine
paintEvent
paintingActive
palette
parent
parentWidget
physicalDpiX
physicalDpiY
pos
previousInFocusChain
property
pyqtConfigure
Each keyword argument is either the name of a Qt property or a Qt signal. raise_
receivers
rect
registerExpressionContextGenerator
Register an expression context generator class that will be used to retrieve an expression context for the widget. releaseKeyboard
releaseMouse
releaseShortcut
removeAction
removeEventFilter
render
render(self, QPainter, targetOffset: QPoint = QPoint(), sourceRegion: QRegion = QRegion(), flags: Union[QWidget.RenderFlags, QWidget.RenderFlag] = QWidget.RenderFlags(QWidget.DrawWindowBackground|QWidget.DrawChildren)) repaint
repaint(self, int, int, int, int) resize
resize(self, int, int) resizeEvent
restoreGeometry
saveGeometry
scroll
scroll(self, int, int, QRect) sender
senderSignalIndex
setAcceptDrops
setAccessibleDescription
setAccessibleName
setAllowEvalErrors
Allow accepting expressions with evaluation errors. setAttribute
setAutoFillBackground
setBackgroundRole
setBaseSize
setBaseSize(self, QSize) setContentsMargins
setContentsMargins(self, QMargins) setContextMenuPolicy
setCursor
setDisabled
setEnabled
setExpression
Sets the current expression text and if applicable also the field. setExpressionDialogTitle
define the title used in the expression dialog setField
sets the current field or expression in the widget setFilters
setFilters allows fitering according to the type of field setFixedHeight
setFixedSize
setFixedSize(self, int, int) setFixedWidth
setFocus
setFocus(self, Qt.FocusReason) setFocusPolicy
setFocusProxy
setFont
setForegroundRole
setGeomCalculator
set the geometry calculator used in the expression dialog setGeometry
setGeometry(self, int, int, int, int) setGraphicsEffect
setHidden
setInputMethodHints
setLayer
Sets the layer used to display the fields and expression. setLayout
setLayoutDirection
setLeftHandButtonStyle
setLocale
setMask
setMask(self, QRegion) setMaximumHeight
setMaximumSize
setMaximumSize(self, QSize) setMaximumWidth
setMinimumHeight
setMinimumSize
setMinimumSize(self, QSize) setMinimumWidth
setMouseTracking
setObjectName
setPalette
setParent
setParent(self, QWidget, Union[Qt.WindowFlags, Qt.WindowType]) setProperty
setRow
sets the current row in the widget setShortcutAutoRepeat
setShortcutEnabled
setSizeIncrement
setSizeIncrement(self, QSize) setSizePolicy
setSizePolicy(self, QSizePolicy.Policy, QSizePolicy.Policy) setStatusTip
setStyle
setStyleSheet
setTabOrder
setTabletTracking
setToolTip
setToolTipDuration
setUpdatesEnabled
setVisible
setWhatsThis
setWindowFilePath
setWindowFlag
setWindowFlags
setWindowIcon
setWindowIconText
setWindowModality
setWindowModified
setWindowOpacity
setWindowRole
setWindowState
setWindowTitle
sharedPainter
show
showEvent
showFullScreen
showMaximized
showMinimized
showNormal
signalsBlocked
size
sizeHint
sizeIncrement
sizePolicy
stackUnder
startTimer
statusTip
style
styleSheet
tabletEvent
testAttribute
thread
timerEvent
toolTip
toolTipDuration
tr
underMouse
ungrabGesture
unsetCursor
unsetLayoutDirection
unsetLocale
update
update(self, QRect) updateGeometry
updateLineEditStyle
updateLineEditStyle will re-style (color/font) the line edit depending on content and status updateMicroFocus
updatesEnabled
visibleRegion
whatsThis
wheelEvent
width
widthMM
winId
window
windowFilePath
windowFlags
windowHandle
windowIcon
windowIconText
windowModality
windowOpacity
windowRole
windowState
windowTitle
windowType
x
y
Attributes
DrawChildren
DrawWindowBackground
IgnoreMask
PdmDepth
PdmDevicePixelRatio
PdmDevicePixelRatioScaled
PdmDpiX
PdmDpiY
PdmHeight
PdmHeightMM
PdmNumColors
PdmPhysicalDpiX
PdmPhysicalDpiY
PdmWidth
PdmWidthMM
allowEvalErrorsChanged
Allow accepting expressions with evaluation errors. customContextMenuRequested
customContextMenuRequested(self, QPoint) [signal] destroyed
destroyed(self, QObject = None) [signal] fieldChanged
the signal is emitted when the currently selected field changes [signal] objectNameChanged
objectNameChanged(self, str) [signal] staticMetaObject
windowIconChanged
windowIconChanged(self, QIcon) [signal] windowIconTextChanged
windowIconTextChanged(self, str) [signal] windowTitleChanged
windowTitleChanged(self, str) [signal] -
actionEvent
()¶
-
allowEvalErrors
(self) → bool¶ Allow accepting expressions with evaluation errors. This can be useful when we are not able to provide an expression context of which we are sure it’s completely populated.
New in version 3.0.
-
allowEvalErrorsChanged
¶ Allow accepting expressions with evaluation errors. This can be useful when we are not able to provide an expression context of which we are sure it’s completely populated.
New in version 3.0: [signal]
-
asExpression
(self) → str¶ Returns the currently selected field or expression. If a field is currently selected, the returned value will be converted to a valid expression referencing this field (ie enclosing the field name with appropriate quotations).
New in version 2.14.
-
changeEvent
(self, event: QEvent)¶
-
childEvent
()¶
-
closeEvent
()¶
-
connectNotify
()¶
-
contextMenuEvent
()¶
-
create
()¶
-
currentField
(self) → Tuple[str, bool, bool]¶ currentField returns the currently selected field or expression if allowed
Parameters: - isExpression – determines if the string returned is the name of a field or an expression
- isValid – determines if the expression (or field) returned is valid
-
currentFieldChanged
(self)¶
-
currentText
(self) → str¶ Return the current text that is set in the expression area
-
customEvent
()¶
-
destroy
()¶
-
disconnectNotify
()¶
-
dragEnterEvent
()¶
-
dragLeaveEvent
()¶
-
dragMoveEvent
()¶
-
dropEvent
()¶
-
editExpression
(self)¶ open the expression dialog to edit the current or add a new expression
-
enterEvent
()¶
-
event
()¶
-
expression
(self) → str¶ Returns the currently selected field or expression. If a field is currently selected, the returned value will be converted to a valid expression referencing this field (ie enclosing the field name with appropriate quotations).
Alias for asExpression()
New in version 3.0.
-
expressionDialogTitle
(self) → str¶ return the title used for the expression dialog
-
expressionEdited
(self, expression: str)¶ when expression is edited by the user in the line edit, it will be checked for validity
-
expressionEditingFinished
(self)¶ when expression has been edited (finished) it will be added to the model
-
fieldChanged
¶ the signal is emitted when the currently selected field changes [signal] fieldChanged signal with indication of the validity of the expression [signal]
-
filters
(self) → QgsFieldProxyModel.Filters¶ currently used filter on list of fields
-
focusInEvent
()¶
-
focusNextChild
()¶
-
focusNextPrevChild
()¶
-
focusOutEvent
()¶
-
focusPreviousChild
()¶
-
hideEvent
()¶
-
initPainter
()¶
-
inputMethodEvent
()¶
-
isExpression
(self) → bool¶ If the content is not just a simple field this method will return true.
-
isExpressionValid
(self, expressionStr: str) → bool¶
-
isSignalConnected
()¶
-
isValidExpression
(self, expressionError: str = '') → bool¶ Return true if the current expression is valid
-
keyPressEvent
()¶
-
keyReleaseEvent
()¶
-
layer
(self) → QgsVectorLayer¶ Returns the layer currently associated with the widget.
See also
-
leaveEvent
()¶
-
metric
()¶
-
mouseDoubleClickEvent
()¶
-
mouseMoveEvent
()¶
-
mousePressEvent
()¶
-
mouseReleaseEvent
()¶
-
moveEvent
()¶
-
nativeEvent
()¶
-
paintEvent
()¶
-
receivers
()¶
-
registerExpressionContextGenerator
(self, generator: QgsExpressionContextGenerator)¶ Register an expression context generator class that will be used to retrieve an expression context for the widget.
Parameters: generator – A QgsExpressionContextGenerator class that will be used to create an expression context when required.
New in version 3.0.
-
resizeEvent
()¶
-
sender
()¶
-
senderSignalIndex
()¶
-
setAllowEvalErrors
(self, allowEvalErrors: bool)¶ Allow accepting expressions with evaluation errors. This can be useful when we are not able to provide an expression context of which we are sure it’s completely populated.
New in version 3.0.
-
setExpression
(self, expression: str)¶ Sets the current expression text and if applicable also the field. Alias for setField.
New in version 3.0.
-
setExpressionDialogTitle
(self, title: str)¶ define the title used in the expression dialog
-
setField
(self, fieldName: str)¶ sets the current field or expression in the widget
-
setFilters
(self, filters: Union[QgsFieldProxyModel.Filters, QgsFieldProxyModel.Filter])¶ setFilters allows fitering according to the type of field
-
setGeomCalculator
(self, da: QgsDistanceArea)¶ set the geometry calculator used in the expression dialog
-
setLayer
(self, layer: QgsMapLayer)¶ Sets the layer used to display the fields and expression.
See also
-
setLeftHandButtonStyle
(self, isLeft: bool)¶
-
setRow
(self, row: int)¶ sets the current row in the widget
-
showEvent
()¶
-
tabletEvent
()¶
-
timerEvent
()¶
-
updateLineEditStyle
(self, expression: str = '')¶ updateLineEditStyle will re-style (color/font) the line edit depending on content and status
Parameters: expression – if expression is given it will be evaluated for the given string, otherwise it takes current expression from the model
-
updateMicroFocus
()¶
-
wheelEvent
()¶
-