I’ve been attempting to create a plugin with the help of google’s gemini using the QField 4.0.6 AppImage but have run into some issues:
- Issues with standard methods for accessing project and layers
- Means of creating a feature without a GPS device present
- Camera
I was hoping to make more progress in desktop before I start testing via zips to my phone. I was wondering how other people are working on plugins.
- Building from source / using Windows / Mac?
- Faking location
- Can a web cam act as a camera for QField?
- AppImage and running a less sandboxed environment?
Any hints or tips on setup would be much appreciated. I’ll paste below the summary of the struggles. Take with a pinch of salt - it’s an AI summary.
Summary of QML Plugin Issues: QField Linux AppImage
The Core Issue: Environment Sandboxing
The primary challenge is that the QML/JavaScript engine within the Linux AppImage appears to be strictly sandboxed or “decoupled” from the internal QGIS/QField object tree. While the UI loads correctly, the API bridges are either missing or returning null.
1. Restricted Access to the Project Object
Standard methods for accessing the project and its layers fail consistently:
-
iface.activeProjectandiface.projectreturnnullor are reported as “Hidden.” -
iface.mainWindow().activeLayer(as a property) andactiveLayer()(as a function) both fail to return the currently highlighted layer in the sidebar. -
Recursive searches through
iface.mapCanvas().layers()orlayerStackreturnundefined, suggesting the MapCanvas object is not exposing its layer registry to the QML context.
2. Inaccessible Hardware/UI Functions
The AppImage environment seems to block “Cross-Talk” between the plugin and the system hardware:
-
iface.nativeCamera()andiface.takePhoto(): Both returnTypeError: not a function, indicating the camera bridge isn’t initialized or exposed to the plugin. -
iface.digitizeFeature(): This core function (which should trigger the standard “Add Feature” UI) is inaccessible, leading to a “Hardware Lock” error.
3. Property vs. Function Discrepancies
There is an inconsistency in how the API is mapped in the AppImage build:
- For example,
mapCanvas().centeris treated as a Property (variable) rather than a Functioncenter(). This suggests the QML wrapper in the AppImage might be using an older or non-standard mapping compared to the Android/Windows versions.