Class: QgsIdentifyMenu¶
- class qgis.gui.QgsIdentifyMenu¶
Bases:
PyQt5.QtWidgets.QMenu
The
QgsIdentifyMenu
class builds a menu to be used with identify results (QgsMapToolIdentify
). It is customizable and can display attribute actions (QgsAction
) as well as map layer actions (seeQgsMapLayerAction
). It can also embed custom map layer actions, defined for this menu exclusively. If used in aQgsMapToolIdentify
, it is accessible viaQgsMapToolIdentify.identifyMenu()
and can be customized in the map tool sub-class.QgsIdentifyMenu(canvas:
QgsMapCanvas
)QgsIdentifyMenu
is a menu to be used to choose within a list of QgsMapTool.IdentifyReultsMethods
adds a new custom action to the menu
- rtype:
bool
- param e:
- type idResults:
Iterable[QgsMapToolIdentify.IdentifyResult]
- rtype:
bool
Returns an expression context scope used to resolve underlying actions.
Searches for features on the map
canvas
, which are located at the specifiedevent
point.- rtype:
int
- rtype:
int
remove all custom actions from the menu to be built
- rtype:
bool
define if the menu executed can return multiple results (e.g. all results or all identified features of a vector layer).
define if the menu will be shown with a single identify result
Sets an expression context scope used to resolve underlying actions.
Defines the maximum number of features displayed in the menu for vector layers (default is 10).
Defines the maximum number of layers displayed in the menu (default is 10).
setResultsIfExternalAction if set to
False
(default) the menu will not return any results if an external action has been triggereddefine if attribute actions(1) and map layer actions(2) can be listed and run from the menu
- rtype:
bool
Applies style from the settings to the highlight
Attributes
- class ActionData¶
Bases:
sip.wrapper
Constructor for ActionData
QgsIdentifyMenu.ActionData(layer:
QgsMapLayer
, mapLayerAction:QgsMapLayerAction
= None)QgsIdentifyMenu.ActionData(layer:
QgsMapLayer
, fid: int, mapLayerAction:QgsMapLayerAction
= None)QgsIdentifyMenu.ActionData(QgsIdentifyMenu.ActionData)
- mAllResults¶
- mFeatureId¶
- mIsExternalAction¶
- mIsValid¶
- mLayer¶
- mLevel¶
- mMapLayerAction¶
- FeatureLevel = 1¶
- LayerLevel = 0¶
- class MenuLevel¶
Bases:
int
- actionEvent(self, QActionEvent)¶
- addCustomAction(self, action: QgsMapLayerAction)¶
adds a new custom action to the menu
- Parameters:
action (QgsMapLayerAction) –
- allowMultipleReturn(self) bool ¶
- Return type:
bool
- changeEvent(self, QEvent)¶
- childEvent(self, QChildEvent)¶
- closeEvent(self, e: QCloseEvent)¶
- Parameters:
e (QCloseEvent) –
- columnCount(self) int ¶
- connectNotify(self, QMetaMethod)¶
- contextMenuEvent(self, QContextMenuEvent)¶
- create(self, window: PyQt5.sip.voidptr = 0, initializeWindow: bool = True, destroyOldWindow: bool = True)¶
- customEvent(self, QEvent)¶
- destroy(self, destroyWindow: bool = True, destroySubWindows: bool = True)¶
- disconnectNotify(self, QMetaMethod)¶
- dragEnterEvent(self, QDragEnterEvent)¶
- dragLeaveEvent(self, QDragLeaveEvent)¶
- dragMoveEvent(self, QDragMoveEvent)¶
- dropEvent(self, QDropEvent)¶
- enterEvent(self, QEvent)¶
- event(self, QEvent) bool ¶
- exec(self, idResults: Iterable[QgsMapToolIdentify.IdentifyResult], pos: QPoint) List[QgsMapToolIdentify.IdentifyResult] ¶
- exec(None) None
- Parameters:
idResults (Iterable[QgsMapToolIdentify.IdentifyResult]) – the list of identify results to choose within
pos (QPoint) – the position where the menu will be executed
- Return type:
- execWithSingleResult(self) bool ¶
- Return type:
bool
- expressionContextScope(self) QgsExpressionContextScope ¶
Returns an expression context scope used to resolve underlying actions.
New in version 3.0.
- Return type:
- findFeaturesOnCanvas(event: QgsMapMouseEvent, canvas: QgsMapCanvas, geometryTypes: object) List[QgsMapToolIdentify.IdentifyResult] ¶
Searches for features on the map
canvas
, which are located at the specifiedevent
point.The
geometryTypes
argument lists acceptable geometry types.This method searches through all layers on the canvas, attempting to find matching features at the event point.
New in version 3.26.
- Parameters:
event (QgsMapMouseEvent) –
canvas (QgsMapCanvas) –
geometryTypes (object) –
- Return type:
- focusInEvent(self, QFocusEvent)¶
- focusNextChild(self) bool ¶
- focusNextPrevChild(self, bool) bool ¶
- focusOutEvent(self, QFocusEvent)¶
- focusPreviousChild(self) bool ¶
- hideEvent(self, QHideEvent)¶
- initPainter(self, QPainter)¶
- initStyleOption(self, QStyleOptionMenuItem, QAction)¶
- inputMethodEvent(self, QInputMethodEvent)¶
- isSignalConnected(self, QMetaMethod) bool ¶
- keyPressEvent(self, QKeyEvent)¶
- keyReleaseEvent(self, QKeyEvent)¶
- leaveEvent(self, QEvent)¶
- maxFeatureDisplay(self) int ¶
- Return type:
int
- maxLayerDisplay(self) int ¶
- Return type:
int
- metric(self, QPaintDevice.PaintDeviceMetric) int ¶
- mouseDoubleClickEvent(self, QMouseEvent)¶
- mouseMoveEvent(self, QMouseEvent)¶
- mousePressEvent(self, QMouseEvent)¶
- mouseReleaseEvent(self, QMouseEvent)¶
- moveEvent(self, QMoveEvent)¶
- nativeEvent(self, Union[QByteArray, bytes, bytearray], PyQt5.sip.voidptr) Tuple[bool, int] ¶
- paintEvent(self, QPaintEvent)¶
- receivers(self, PYQT_SIGNAL) int ¶
- removeCustomActions(self)¶
remove all custom actions from the menu to be built
- resizeEvent(self, QResizeEvent)¶
- resultsIfExternalAction(self) bool ¶
- Return type:
bool
- sender(self) QObject ¶
- senderSignalIndex(self) int ¶
- setAllowMultipleReturn(self, multipleReturn: bool)¶
define if the menu executed can return multiple results (e.g. all results or all identified features of a vector layer)
- Parameters:
multipleReturn (bool) –
- setExecWithSingleResult(self, execWithSingleResult: bool)¶
define if the menu will be shown with a single identify result
- Parameters:
execWithSingleResult (bool) –
- setExpressionContextScope(self, scope: QgsExpressionContextScope)¶
Sets an expression context scope used to resolve underlying actions.
New in version 3.0.
- Parameters:
scope (QgsExpressionContextScope) –
- setMaxFeatureDisplay(self, maxFeatureDisplay: int)¶
Defines the maximum number of features displayed in the menu for vector layers (default is 10).
Note
0 is unlimited.
- Parameters:
maxFeatureDisplay (int) –
- setMaxLayerDisplay(self, maxLayerDisplay: int)¶
Defines the maximum number of layers displayed in the menu (default is 10).
Note
0 is unlimited.
- Parameters:
maxLayerDisplay (int) –
- setResultsIfExternalAction(self, resultsIfExternalAction: bool)¶
setResultsIfExternalAction if set to
False
(default) the menu will not return any results if an external action has been triggeredNote
external action can be either custom actions or feature / map layer actions (
setShowFeatureActions()
)- Parameters:
resultsIfExternalAction (bool) –
- setShowFeatureActions(self, showFeatureActions: bool)¶
define if attribute actions(1) and map layer actions(2) can be listed and run from the menu
Note
custom actions will be shown in any case if they exist.
Note
attribute actions are defined by the user in the layer properties
QgsAction
Note
map layer actions are built-in c++ actions or actions which are defined by a Python plugin
QgsMapLayerActionRegistry
- Parameters:
showFeatureActions (bool) –
- showEvent(self, QShowEvent)¶
- showFeatureActions(self) bool ¶
- Return type:
bool
- styleHighlight(highlight: QgsHighlight)¶
Applies style from the settings to the highlight
New in version 3.8.
- Parameters:
highlight (QgsHighlight) –
- tabletEvent(self, QTabletEvent)¶
- timerEvent(self, QTimerEvent)¶
- updateMicroFocus(self)¶
- wheelEvent(self, QWheelEvent)¶