QgsLayerDefinition class
The QgsLayerDefinition class holds generic methods for loading/exporting QLR files.
Contents
- Reference
QLR files are an export of the layer xml including the style and datasource location. There is no link to the QLR file once loaded. Consider the QLR file a mini project file for layers and styles. QLR files also store the layer tree info for the exported layers, including group information.
Public types
- class DependencySorter
- Class used to work with layer dependencies stored in a XML project or layer definition file.
Public static functions
- static auto exportLayerDefinition(QString path, const QList<QgsLayerTreeNode*>& selectedTreeNodes, QString& errorMessage) -> bool
- Export the selected layer tree nodes to a QLR file.
- static auto exportLayerDefinition(QDomDocument doc, const QList<QgsLayerTreeNode*>& selectedTreeNodes, QString& errorMessage, const QgsReadWriteContext& context) -> bool
- Export the selected layer tree nodes to a QLR-XML document.
- static auto exportLayerDefinitionLayers(const QList<QgsMapLayer*>& layers, const QgsReadWriteContext& context) -> QDomDocument
- Returns the given layer as a layer definition document Layer definitions store the data source as well as styling and custom properties.
- static auto loadLayerDefinition(const QString& path, QgsProject* project, QgsLayerTreeGroup* rootGroup, QString& errorMessage) -> bool
- Loads the QLR at path into QGIS. New layers are added to given project into layer tree specified by rootGroup.
- static auto loadLayerDefinition(QDomDocument doc, QgsProject* project, QgsLayerTreeGroup* rootGroup, QString& errorMessage, QgsReadWriteContext& context) -> bool
- Loads the QLR from the XML document. New layers are added to given project into layer tree specified by rootGroup.
- static auto loadLayerDefinitionLayers(QDomDocument& document, QgsReadWriteContext& context) -> QList<QgsMapLayer*>
- Creates new layers from a layer definition document.
- static auto loadLayerDefinitionLayers(const QString& qlrfile) -> QList<QgsMapLayer*>
- Creates new layers from a layer definition file (.QLR) This is a low-level routine that does not resolve layer ID conflicts, dependencies and joins.
Function documentation
static QDomDocument QgsLayerDefinition:: exportLayerDefinitionLayers(const QList<QgsMapLayer*>& layers,
const QgsReadWriteContext& context)
Returns the given layer as a layer definition document Layer definitions store the data source as well as styling and custom properties.
Layer definitions can be used to load a layer and styling all from a single file.
This is a low-level routine that does not write layer tree.
static QList<QgsMapLayer*> QgsLayerDefinition:: loadLayerDefinitionLayers(QDomDocument& document,
QgsReadWriteContext& context)
Creates new layers from a layer definition document.
This is a low-level routine that does not resolve layer ID conflicts, dependencies and joins
static QList<QgsMapLayer*> QgsLayerDefinition:: loadLayerDefinitionLayers(const QString& qlrfile)
Creates new layers from a layer definition file (.QLR) This is a low-level routine that does not resolve layer ID conflicts, dependencies and joins.