Class: QgsIdentifyMenu¶
Builds a menu to be used with identify results.
It is customizable and can display attribute actions
(QgsAction) as well as map layer actions
(QgsMapLayerAction). It can also embed custom map layer
actions, defined for this menu exclusively. If used in a
QgsMapToolIdentify, it is accessible via
QgsMapToolIdentify.identifyMenu() and can be customized in
the map tool sub-class.
See also
Class Hierarchy¶
Base classes¶
- class qgis.gui.QgsIdentifyMenu[source]¶
Bases:
QMenu- __init__(canvas: QgsMapCanvas | None)
QgsIdentifyMenu is a menu to be used to choose within a list of QgsMapTool.IdentifyReults
- Parameters:
canvas (Optional[QgsMapCanvas])
- class ActionData¶
- class ActionData(layer: QgsMapLayer | None, mapLayerAction: QgsMapLayerAction | None = None)
- class ActionData(layer: QgsMapLayer | None, fid: int, mapLayerAction: QgsMapLayerAction | None = None)
- class ActionData(a0: QgsIdentifyMenu.ActionData)
Bases:
object- mAllResults¶
- mFeatureId¶
- mIsExternalAction¶
- mIsValid¶
- mLayer¶
- mLevel¶
- mMapLayerAction¶
- FeatureLevel = 1¶
- LayerLevel = 0¶
- class MenuLevel¶
Bases:
int
- addCustomAction(self, action: QgsMapLayerAction | None)[source]¶
adds a new custom action to the menu
- Parameters:
action (Optional[QgsMapLayerAction])
- exec(self, idResults: Iterable[QgsMapToolIdentify.IdentifyResult], pos: QPoint) List[QgsMapToolIdentify.IdentifyResult]¶
- exec()
- 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:
- expressionContextScope(self) QgsExpressionContextScope[source]¶
Returns an expression context scope used to resolve underlying actions.
- Return type:
- static findFeaturesOnCanvas(event: QgsMapMouseEvent | None, canvas: QgsMapCanvas | None, geometryTypes: Iterable[Qgis.GeometryType]) List[QgsMapToolIdentify.IdentifyResult]¶
Searches for features on the map
canvas, which are located at the specifiedeventpoint.The
geometryTypesargument lists acceptable geometry types.This method searches through all layers on the canvas, attempting to find matching features at the event point.
Added in version 3.26.
- Parameters:
event (Optional[QgsMapMouseEvent])
canvas (Optional[QgsMapCanvas])
geometryTypes (Iterable[Qgis.GeometryType])
- Return type:
- signal messageDiscarded[source]¶
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.
- signal messageEmitted[source]¶
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.
- setAllowMultipleReturn(self, multipleReturn: bool)[source]¶
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)[source]¶
define if the menu will be shown with a single identify result
- Parameters:
execWithSingleResult (bool)
- setExpressionContextScope(self, scope: QgsExpressionContextScope)[source]¶
Sets an expression context scope used to resolve underlying actions.
- Parameters:
scope (QgsExpressionContextScope)
- setMaxFeatureDisplay(self, maxFeatureDisplay: int)[source]¶
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)[source]¶
Defines the maximum number of layers displayed in the menu (default is 10).
Note
0 is unlimited.
- Parameters:
maxLayerDisplay (int)
- setResultsIfExternalAction(self, resultsIfExternalAction: bool)[source]¶
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)[source]¶
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)
- static styleHighlight(highlight: QgsHighlight | None)[source]¶
Applies style from the settings to the highlight
Deprecated since version 3.40: Use
QgsHighlight.applyDefaultStyle()instead.- Parameters:
highlight (Optional[QgsHighlight])