# Access non geometry layer for Plugin

**URL:** <https://community.qfield.org/t/access-non-geometry-layer-for-plugin/376>\
**Category:** Ask the Community\
**Tags:** gh-import\
**Created:** [14 May 2025 02:11 UTC](https://community.qfield.org/t/access-non-geometry-layer-for-plugin/376 "2025-05-14T02:11:39Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![system](https://europe1.discourse-cdn.com/flex018/uploads/qfield/original/1X/7d3726da0ef5099a1e135505c03d2f125d527aae.png) [@system](https://community.qfield.org/u/system)\
**Post date:** [14 May 2025 02:11 UTC](https://community.qfield.org/t/access-non-geometry-layer-for-plugin/376/1 "2025-05-14T02:11:39Z")

</div>

Hi,

I’m attempting to access a non-geometrical layer to enumerate all values within a specific field. While I can retrieve `QgsVectorLayer `instances using `mapCanvas.mapSettings.layers`, I’ve noted that, as specified in the [QField source code](https://github.com/opengisch/QField/blob/f3c1fb9b351bba39ed7771efb486e898a11432e5/src/core/qgsquick/qgsquickmapsettings.h#L114)

> non-spatial layers are automatically excluded from this list.

Additionally, I’ve observed that `dashBoard.activeLayer` provides access to the currently active layer. However, my requirement is to access any layer within the project, not just the active one.

Is there a method to access non-geometrical layers within QField’s QML environment?

Below my qml to test layer acces :

```auto
import QtQuick

Item {
  id: plugin

  property var mapCanvas: iface.findItemByObjectName('mapCanvas')

  Component.onCompleted: {

    let layers = mapCanvas.mapSettings.layers;
    let concatenatedLayerNames = layers.map(layer => layer.name).join(", ");
    iface.logMessage(`Layer Names: ${concatenatedLayerNames}`);

    let firstLayer = layers[0];
    iface.logMessage(`Layer Name: ${firstLayer.name}`);
    iface.logMessage(`Fields Name: ${firstLayer.fields.names}`);

    let fieldName = 'PLTM_PARC';
    iface.logMessage(`Index of ${fieldName} is ${firstLayer.fields.indexOf(fieldName)}`);
    
  }
}

```

* * *

_Imported from [GitHub discussion](https://github.com/opengisch/qfield/discussions/5877) by @paul-carteron on 2024-12-04T14:32:04Z_

---

<div class="post-metadata">

**Author:** ![system](https://europe1.discourse-cdn.com/flex018/uploads/qfield/original/1X/7d3726da0ef5099a1e135505c03d2f125d527aae.png) [@system](https://community.qfield.org/u/system)\
**Post date:** [14 May 2025 02:11 UTC](https://community.qfield.org/t/access-non-geometry-layer-for-plugin/376/2 "2025-05-14T02:11:41Z")

</div>

paul-carteron , have you tried this function: [QGIS API Documentation: QgsProject Class Reference](https://api.qgis.org/api/classQgsProject.html#a935efacacb942a15afe19728233e35c3) ? In the qml plugin environment you can access the current project via the qgisProject object.

So provided you know your layer name you could do qgisProject.mapLayersByName(“my layer”).

* * *

_Imported from [GitHub comment](https://github.com/opengisch/QField/discussions/5877#discussioncomment-11462450) by @nirvn on 2024-12-04T14:52:11Z_

---

<div class="post-metadata">

**Author:** ![system](https://europe1.discourse-cdn.com/flex018/uploads/qfield/original/1X/7d3726da0ef5099a1e135505c03d2f125d527aae.png) [@system](https://community.qfield.org/u/system)\
**Post date:** [14 May 2025 02:11 UTC](https://community.qfield.org/t/access-non-geometry-layer-for-plugin/376/3 "2025-05-14T02:11:42Z")

</div>

Pro tip: in the QGIS documentation, you can see properties accessible in QML within the properties section, and you can see which functions are exposed by spotting the Q\_INVOKABLE tags.

* * *

_Imported from [GitHub comment](https://github.com/opengisch/QField/discussions/5877#discussioncomment-11462459) by @nirvn on 2024-12-04T14:53:18Z_

---

<div class="post-metadata">

**Author:** ![system](https://europe1.discourse-cdn.com/flex018/uploads/qfield/original/1X/7d3726da0ef5099a1e135505c03d2f125d527aae.png) [@system](https://community.qfield.org/u/system)\
**Post date:** [14 May 2025 02:11 UTC](https://community.qfield.org/t/access-non-geometry-layer-for-plugin/376/4 "2025-05-14T02:11:43Z")

</div>

nirvn It works perfectly, thank you!

I wasn’t aware that `qgisProject` is accessible in QField plugins. What I take away after watching your [presentation](https://drive.google.com/file/d/1s5SD-JpCq9QHoIbmOMEqDsTyGSsN6QrC/view), I that i can use in Qfield Plugin :

- [All Q\_INVOKABLE iface functions](https://github.com/opengisch/QField/blob/master/src/core/appinterface.h) ;
- [Any QML components defined in qml/qgismobileapp.qml](https://github.com/opengisch/QField/blob/master/src/qml/qgismobileapp.qml), as long as they have an `objectName` property ;
- [Utility classes from core/utils](https://github.com/opengisch/QField/tree/master/src/core/utils), offering reusable functions for common tasks ;
- [QField custom QML components from Theme](https://github.com/opengisch/QField/tree/master/src/qml/imports/Theme), which include various UI and styling elements ;
- [Qgs classes initialized in core/qgismobileapp.cpp](https://github.com/opengisch/QField/blob/f3c1fb9b351bba39ed7771efb486e898a11432e5/src/core/qgismobileapp.cpp#L365), specifically within the initDeclarative function ;
- (and also the pro tip you just gave me)

You - obviously - already know all this, but I’m writing more with the goal of documenting and centralizing ressources. With that in mind, I couldn’t find where it’s explicitly documented that `qgisProject` exposes the QgsProject class. Do you know where I can find where this is defined?

* * *

_Imported from [GitHub comment](https://github.com/opengisch/QField/discussions/5877#discussioncomment-11463167) by @paul-carteron on 2024-12-04T15:50:27Z_

---

<div class="post-metadata">

**Author:** ![system](https://europe1.discourse-cdn.com/flex018/uploads/qfield/original/1X/7d3726da0ef5099a1e135505c03d2f125d527aae.png) [@system](https://community.qfield.org/u/system)\
**Post date:** [14 May 2025 02:11 UTC](https://community.qfield.org/t/access-non-geometry-layer-for-plugin/376/5 "2025-05-14T02:11:45Z")

</div>

paul-carteron , you’d see it exposed in the QML context here: [https://github.com/opengisch/QField/blob/f3c1fb9b351bba39ed7771efb486e898a11432e5/src/core/qgismobileapp.cpp#L575](https://github.com/opengisch/QField/blob/f3c1fb9b351bba39ed7771efb486e898a11432e5/src/core/qgismobileapp.cpp#L575)

We’d most welcome documentation additions once you feel happy about your gathering of resources.

* * *

_Imported from [GitHub comment](https://github.com/opengisch/QField/discussions/5877#discussioncomment-11463244) by @nirvn on 2024-12-04T15:55:18Z_

---

<div class="post-metadata">

**Author:** ![system](https://europe1.discourse-cdn.com/flex018/uploads/qfield/original/1X/7d3726da0ef5099a1e135505c03d2f125d527aae.png) [@system](https://community.qfield.org/u/system)\
**Post date:** [14 May 2025 02:11 UTC](https://community.qfield.org/t/access-non-geometry-layer-for-plugin/376/6 "2025-05-14T02:11:46Z")

</div>

Thanks, I’ll keep that in mind for the documentation suggestion !

* * *

_Imported from [GitHub comment](https://github.com/opengisch/QField/discussions/5877#discussioncomment-11463453) by @paul-carteron on 2024-12-04T16:12:23Z_
