Class: QgsExpressionTreeView¶
- class qgis.gui.QgsExpressionTreeView¶
Bases:
PyQt5.QtWidgets.QTreeView
QgsExpressionTreeView
is a tree view to list all expressions functions, variables and fields that can be used in an expression.See also
New in version 3.14.
QgsExpressionTreeView(parent: QWidget = None) Constructor
Methods
columnCountChanged
columnResized
currentChanged
Returns the current item or a None
Create the expressions JSON document storing all the user expressions to be exported.
Returns the expression context for the widget.
Returns the list of expression items matching a
label
.Load and permanently store the expressions from the expressions JSON document.
This allows loading fields without specifying a layer
Loads the recent expressions from the given
collection
.Loads the user expressions.
Returns the project currently associated with the widget.
Refreshes the content of the tree
Removes the expression
label
from the user stored expressions.rowsAboutToBeRemoved
rowsInserted
rowsRemoved
Adds the current expression to the given
collection
.Stores the user
expression
with givenlabel
andhelpText
.scrollContentsBy
scrollDirtyRegion
selectionChanged
Sets the expression context for the tree view.
Sets layer in order to get the fields and values
Sets the menu provider.
Sets the
project
currently associated with the widget.Sets the text to filter the expression tree
Signals
pyqtSignal(*types, name: str = ..., revision: int = ..., arguments: Sequence = ...) -> PYQT_SIGNAL
pyqtSignal(*types, name: str = ..., revision: int = ..., arguments: Sequence = ...) -> PYQT_SIGNAL
- class MenuProvider¶
Bases:
sip.wrapper
Implementation of this interface can be implemented to allow QgsExpressionTreeView instance to provide custom context menus (opened upon right-click).
New in version 3.14.
QgsExpressionTreeView.MenuProvider() Constructor
QgsExpressionTreeView.MenuProvider(QgsExpressionTreeView.MenuProvider)
- createContextMenu(self, item: QgsExpressionItem) QMenu ¶
Returns a newly created menu instance
- Parameters:
item (QgsExpressionItem) –
- Return type:
QMenu
- actionEvent(self, QActionEvent)¶
- changeEvent(self, QEvent)¶
- childEvent(self, QChildEvent)¶
- closeEditor(self, QWidget, QAbstractItemDelegate.EndEditHint)¶
- closeEvent(self, QCloseEvent)¶
- QgsExpressionTreeView.columnCountChanged(self, int, int)
- columnMoved(self)¶
- QgsExpressionTreeView.columnResized(self, int, int, int)
- commitData(self, QWidget)¶
- connectNotify(self, QMetaMethod)¶
- contextMenuEvent(self, QContextMenuEvent)¶
- create(self, window: PyQt5.sip.voidptr = 0, initializeWindow: bool = True, destroyOldWindow: bool = True)¶
- QgsExpressionTreeView.currentChanged(self, QModelIndex, QModelIndex)
- currentExpressionItemChanged¶
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
- currentItem(self) QgsExpressionItem ¶
Returns the current item or a None
- Return type:
- customEvent(self, QEvent)¶
- destroy(self, destroyWindow: bool = True, destroySubWindows: bool = True)¶
- dirtyRegionOffset(self) QPoint ¶
- disconnectNotify(self, QMetaMethod)¶
- dragEnterEvent(self, QDragEnterEvent)¶
- dragLeaveEvent(self, QDragLeaveEvent)¶
- dragMoveEvent(self, QDragMoveEvent)¶
- drawBranches(self, QPainter, QRect, QModelIndex)¶
- drawFrame(self, QPainter)¶
- drawRow(self, QPainter, QStyleOptionViewItem, QModelIndex)¶
- drawTree(self, QPainter, QRegion)¶
- dropEvent(self, QDropEvent)¶
- dropIndicatorPosition(self) QAbstractItemView.DropIndicatorPosition ¶
- edit(self, QModelIndex)¶
- edit(self, QModelIndex, QAbstractItemView.EditTrigger, QEvent) bool
- editorDestroyed(self, QObject)¶
- enterEvent(self, QEvent)¶
- event(self, QEvent) bool ¶
- eventFilter(self, QObject, QEvent) bool ¶
- executeDelayedItemsLayout(self)¶
- exportUserExpressions(self) QJsonDocument ¶
Create the expressions JSON document storing all the user expressions to be exported.
- Return type:
QJsonDocument
- Returns:
the created expressions JSON file
- expressionContext(self) QgsExpressionContext ¶
Returns the expression context for the widget. The context is used for the expression preview result and for populating the list of available functions and variables.
See also
- Return type:
- expressionItemDoubleClicked¶
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
- findExpressions(self, label: str) List[QgsExpressionItem] ¶
Returns the list of expression items matching a
label
.- Parameters:
label (str) –
- Return type:
List[QgsExpressionItem]
- focusInEvent(self, QFocusEvent)¶
- focusNextChild(self) bool ¶
- focusNextPrevChild(self, bool) bool ¶
- focusOutEvent(self, QFocusEvent)¶
- focusPreviousChild(self) bool ¶
- hideEvent(self, QHideEvent)¶
- horizontalOffset(self) int ¶
- horizontalScrollbarAction(self, int)¶
- horizontalScrollbarValueChanged(self, int)¶
- indexRowSizeHint(self, QModelIndex) int ¶
- initPainter(self, QPainter)¶
- initStyleOption(self, QStyleOptionFrame)¶
- inputMethodEvent(self, QInputMethodEvent)¶
- isIndexHidden(self, QModelIndex) bool ¶
- isSignalConnected(self, QMetaMethod) bool ¶
- keyPressEvent(self, QKeyEvent)¶
- keyReleaseEvent(self, QKeyEvent)¶
- leaveEvent(self, QEvent)¶
- loadExpressionsFromJson(self, expressionsDocument: QJsonDocument)¶
Load and permanently store the expressions from the expressions JSON document.
- Parameters:
expressionsDocument (QJsonDocument) – the parsed expressions JSON file
- loadFieldNames(self, fields: QgsFields)¶
This allows loading fields without specifying a layer
- Parameters:
fields (QgsFields) –
- loadRecent(self, collection: str = '')¶
Loads the recent expressions from the given
collection
. By default it is loaded from the collection “generic”.- Parameters:
collection (str = '') –
- loadUserExpressions(self)¶
Loads the user expressions. This is done on request since it can be very slow if there are thousands of user expressions
- metric(self, QPaintDevice.PaintDeviceMetric) int ¶
- mouseDoubleClickEvent(self, QMouseEvent)¶
- mouseMoveEvent(self, QMouseEvent)¶
- mousePressEvent(self, QMouseEvent)¶
- mouseReleaseEvent(self, QMouseEvent)¶
- moveCursor(self, QAbstractItemView.CursorAction, Union[Qt.KeyboardModifiers, Qt.KeyboardModifier]) QModelIndex ¶
- moveEvent(self, QMoveEvent)¶
- nativeEvent(self, Union[QByteArray, bytes, bytearray], PyQt5.sip.voidptr) Tuple[bool, int] ¶
- paintEvent(self, QPaintEvent)¶
- project(self) QgsProject ¶
Returns the project currently associated with the widget.
See also
- Return type:
- receivers(self, PYQT_SIGNAL) int ¶
- reexpand(self)¶
- refresh(self)¶
Refreshes the content of the tree
- removeFromUserExpressions(self, label: str)¶
Removes the expression
label
from the user stored expressions.- Parameters:
label (str) –
- resizeEvent(self, QResizeEvent)¶
- rowHeight(self, QModelIndex) int ¶
- QgsExpressionTreeView.rowsAboutToBeRemoved(self, QModelIndex, int, int)
- QgsExpressionTreeView.rowsInserted(self, QModelIndex, int, int)
- QgsExpressionTreeView.rowsRemoved(self, QModelIndex, int, int)
- saveToRecent(self, expressionText: str, collection: str = '')¶
Adds the current expression to the given
collection
. By default it is saved to the collection “generic”.- Parameters:
expressionText (str) –
collection (str = '') –
- saveToUserExpressions(self, label: str, expression: str, helpText: str)¶
Stores the user
expression
with givenlabel
andhelpText
.- Parameters:
label (str) –
expression (str) –
helpText (str) –
- scheduleDelayedItemsLayout(self)¶
- QgsExpressionTreeView.scrollContentsBy(self, int, int)
- QgsExpressionTreeView.scrollDirtyRegion(self, int, int)
- selectedIndexes(self) List[QModelIndex] ¶
- QgsExpressionTreeView.selectionChanged(self, QItemSelection, QItemSelection)
- selectionCommand(self, QModelIndex, event: QEvent = None) QItemSelectionModel.SelectionFlags ¶
- sender(self) QObject ¶
- senderSignalIndex(self) int ¶
- setDirtyRegion(self, QRegion)¶
- setExpressionContext(self, context: QgsExpressionContext)¶
Sets the expression context for the tree view. The context is used to populate the list of available functions and variables.
- Parameters:
context (QgsExpressionContext) – expression context
See also
- setLayer(self, layer: QgsVectorLayer)¶
Sets layer in order to get the fields and values
- Parameters:
layer (QgsVectorLayer) –
- setMenuProvider(self, provider: QgsExpressionTreeView.MenuProvider)¶
Sets the menu provider. This does not take ownership of the provider
- Parameters:
provider (QgsExpressionTreeView.MenuProvider) –
- setProject(self, project: QgsProject)¶
Sets the
project
currently associated with the widget. This controls which layers and relations and other project-specific items are shown in the widget.See also
- Parameters:
project (QgsProject) –
- setSearchText(self, text: str)¶
Sets the text to filter the expression tree
- Parameters:
text (str) –
- setSelection(self, QRect, Union[QItemSelectionModel.SelectionFlags, QItemSelectionModel.SelectionFlag])¶
- setState(self, QAbstractItemView.State)¶
- QgsExpressionTreeView.setViewportMargins(self, int, int, int, int)
- setViewportMargins(self, QMargins) None ¶
- showEvent(self, QShowEvent)¶
- sizeHintForColumn(self, int) int ¶
- startDrag(self, Union[Qt.DropActions, Qt.DropAction])¶
- state(self) QAbstractItemView.State ¶
- tabletEvent(self, QTabletEvent)¶
- timerEvent(self, QTimerEvent)¶
- updateEditorData(self)¶
- updateEditorGeometries(self)¶
- updateGeometries(self)¶
- updateMicroFocus(self)¶
- verticalOffset(self) int ¶
- verticalScrollbarAction(self, int)¶
- verticalScrollbarValueChanged(self, int)¶
- viewOptions(self) QStyleOptionViewItem ¶
- viewportEvent(self, QEvent) bool ¶
- viewportMargins(self) QMargins ¶
- viewportSizeHint(self) QSize ¶
- visualRegionForSelection(self, QItemSelection) QRegion ¶
- wheelEvent(self, QWheelEvent)¶