Class: QgsProviderSublayerModel¶
A model for representing the sublayers present in a URI.
QgsProviderSublayerModel
is designed to present a tree view
of the sublayers available for a URI, including any vector, raster or
mesh sublayers present.
Additionally, QgsProviderSublayerModel
can include some
non-sublayer items, e.g. in order to represent other content available
for a URI, such as embedded project items. The non-sublayer items can be
added by calling addNonLayerItem()
.
Added in version 3.22.
Class Hierarchy¶
Base classes¶
Subclasses¶
A model for representing the sublayers present in a URI for the |
Enums
Model columns |
|
Custom model roles |
Methods
Adds a non-layer item (e.g. an embedded QGIS project item) to the model. |
|
Returns the non layer item corresponding to the given index. |
|
Returns the sublayer corresponding to the given index. |
|
Sets the sublayer details to show in the model. |
|
Returns the sublayer details shown in the model. |
- class qgis.core.QgsProviderSublayerModel[source]¶
Bases:
QAbstractItemModel
- __init__(parent: QObject | None = None)
Constructor for QgsProviderSublayerModel, with the specified
parent
object.- Parameters:
parent (Optional[QObject] = None)
- class Column(*values)¶
Bases:
IntEnum
Model columns
Name
: Layer nameDescription
: Layer description
- Description = 1¶
- Name = 0¶
- class NonLayerItem[source]¶
Bases:
object
Contains details for a non-sublayer item to include in a QgsProviderSublayerModel.
Added in version 3.22.
- setDescription(self, description: str | None)[source]¶
Sets the item’s
description
.See also
- Parameters:
description (Optional[str])
- setName(self, name: str | None)[source]¶
Sets the item’s
name
.See also
- Parameters:
name (Optional[str])
- setType(self, type: str | None)[source]¶
Sets the item’s
type
.See also
- Parameters:
type (Optional[str])
- class Role(*values)¶
Bases:
IntEnum
Custom model roles
ProviderKey
: Provider keyLayerType
: Layer typeUri
: Layer URIName
: Layer nameDescription
: Layer descriptionPath
: Layer pathFeatureCount
: Feature count (for vector sublayers)WkbType
: WKB geometry type (for vector sublayers)GeometryColumnName
: Geometry column name (for vector sublayers)LayerNumber
: Layer numberIsNonLayerItem
:True
if item is a non-sublayer item (e.g. an embedded project)NonLayerItemType
: Item type (for non-sublayer items)Flags
: Sublayer flags
- Description = 261¶
- FeatureCount = 263¶
- Flags = 269¶
- GeometryColumnName = 265¶
- IsNonLayerItem = 267¶
- LayerNumber = 266¶
- LayerType = 258¶
- Name = 260¶
- NonLayerItemType = 268¶
- Path = 262¶
- ProviderKey = 257¶
- Uri = 259¶
- WkbType = 264¶
- addNonLayerItem(self, item: QgsProviderSublayerModel.NonLayerItem)[source]¶
Adds a non-layer item (e.g. an embedded QGIS project item) to the model.
- Parameters:
- indexToNonLayerItem(self, index: QModelIndex) QgsProviderSublayerModel.NonLayerItem [source]¶
Returns the non layer item corresponding to the given
index
.- Parameters:
index (QModelIndex)
- Return type:
- indexToSublayer(self, index: QModelIndex) QgsProviderSublayerDetails [source]¶
Returns the sublayer corresponding to the given
index
.- Parameters:
index (QModelIndex)
- Return type:
- setSublayerDetails(self, details: Iterable[QgsProviderSublayerDetails])[source]¶
Sets the sublayer
details
to show in the model.See also
- Parameters:
details (Iterable[QgsProviderSublayerDetails])
- sublayerDetails(self) List[QgsProviderSublayerDetails] ¶
Returns the sublayer details shown in the model.
See also
- Return type: