Hi,
I’ve been working on QField plugin and recently started exploring the use of signals. If I understand correctly, signals from QGIS classes can be accessed in QML when the class is exposed. For example, I’ve successfully connected to signals from QgsVectorLayer
like featureAdded
and geometryChanged
in QML using the following:
property var my_layer: qgisProject.mapLayersByName("my_layer")[0]
Connections {
target: my_layer
onGeometryChanged: {
iface.logMessage("onGeometryChanged")
}
onFeatureAdded: {
iface.logMessage("onFeatureAdded")
}
}
This works perfectly, but I’m trying to understand how to confirm whether signals for a specific class are fully exposed to QML or if there’s a custom mechanism in QField that bridges these signals.
From my understanding, QgsVectorLayer
is exposed to QML with :
qmlRegisterType<QgsVectorLayer>( "org.qgis", 1, 0, "VectorLayer")
Does this mean that all QgsVectorLayer
signals (like featureAdded
, geometryChanged
, committedFeaturesAdded
, etc.) are automatically available in QML?
I’ve reviewed files like layerobserver.cpp and featurelistmodel.cpp, which appear to connect QgsVectorLayer
signals internally. However, in the plugin I use target:my_layer
(a QgsVectorLayer
instance) and not to something like layerObserver
.
I’d appreciate it if you could clarify:
- Are all
QgsVectorLayer
signals exposed to QML by default, or is there a custom mechanism in QField for signal exposure? - If not all signals are exposed, are there specific parts of the codebase I can refer to confirm which signals are available for a given class in QField?
Apologies if my question isn’t clear—I’m still learning about Plugin development with Qfield.
Thank you in advance !
Imported from GitHub discussion by @paul-carteron on 2024-12-13T10:54:55Z