[QGIS-Developer] Problem with default "identify" action in python

Szymon Ślęczka szymonsleczka7 at gmail.com
Tue Mar 7 01:21:24 PST 2023


Hi everyone,
I have got problem with QgsMapToolIdentifyFeature in LayerSelection mode.
I create my own class called myFeature which inherits
QgsMapToolIdentifyFeature.
This class has got variable "menu" which is identifyMenu from
QgsMapToolIdentifyFeature class.
In myFeature class I create my custom action object "act" and I added it to
identifyMenu as custom action.

My "act" is a object of MyMapLayerAction class inherits from
QgsMapLayerAction.

Is it any way to override the default "identify" ("identyfikacja" on
screen) action or remove it from identify menu?

My code:

class myFeature(QgsMapToolIdentifyFeature):
    def __init__(self, iface):
        self.iface = iface
        self.canvas = self.iface.mapCanvas()
        self.layer = self.iface.activeLayer()
        super().__init__(self.canvas, self.layer)
        menu = self.identifyMenu()
        act = MyMapLayerAction("Do sth",
                               menu,
                               QgsMapLayerType.VectorLayer,
                               QgsMapLayerAction.SingleFeature)
        menu.addCustomAction(act)

class MyMapLayerAction(QgsMapLayerAction):
    def __init__(self, name, menu, vector, single):
        super().__init__(name, menu, vector, single)




Screen:
[image: image.png]
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/qgis-developer/attachments/20230307/a66707bc/attachment-0001.htm>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image.png
Type: image/png
Size: 28443 bytes
Desc: not available
URL: <http://lists.osgeo.org/pipermail/qgis-developer/attachments/20230307/a66707bc/attachment-0001.png>


More information about the QGIS-Developer mailing list