Plugins: launching from feature selection

I am not able to find the api mechanism that would allow me to launch my plugin when the user clicks on a feature on the map. Does such a mechanism exist?
Possible actions that would serve including:

  • the plugin is simply opened on click of feature (the plugin has access to selected features and their attributes)
  • the project developer can deliver an empty feature form, and the project developer adds the plugin button to the feature form widget or the green bar on top of the feature form widget

@Heather_Hillers , greetings. Here are some answers to your questions, hope it’ll help

Regarding an API / mechanism to hook a plugin into map canvas tap/press, QField has a framework - added in 3.6 - to do just that. You can actually see how it’s done by looking at how QField handle bookmarks overlays (see QField/src/qml/BookmarkRenderer.qml at master · opengisch/QField · GitHub). You could use that to then manually trigger a feature iteration against a given geometry filter expression using the LayerUtils.createFeatureIteratorFromExpression(layer, expression_string) function (see QField/src/core/utils/layerutils.h at master · opengisch/QField · GitHub)

For features list and feature form integration, we have no plugin API mechanism in place. However, you can integrate QML items into the feature form using QML widgets, which are setup in QGIS when configuring your form in drag and drop mode. You can see an example of how this is done in this project we built for QGIS User Conference 2025 (http://qfield.org/conferences-projects/uc2025.zip).

Let us know how it goes! :slight_smile:

Thank you very much for the advice! I am going to try to implement this this week and once my code is all tidy I will post a github link.