QgsMapLayer class
Base class for all map layer types.
Contents
This is the base class for all map layer types (vector, raster).
Derived classes
- class QgsMeshLayer
- Represents a mesh layer supporting display of data on structured or unstructured meshes.
- class QgsPluginLayer
- Base class for plugin layers.
- class QgsRasterLayer
- This class provides qgis with the ability to render raster datasets onto the mapcanvas.
- class QgsVectorLayer
- Represents a vector layer which manages a vector based data sets.
Public types
- enum LayerFlag { Identifiable = 1 << 0, Removable = 1 << 1, Searchable = 1 << 2 }
- Flags for the map layer.
- enum LayerType { VectorLayer, RasterLayer, PluginLayer, MeshLayer }
- Types of layers that can be added to a map.
- enum PropertyType { Style = 0, Metadata }
- Maplayer has a style and a metadata property.
- enum StyleCategory { LayerConfiguration = 1 << 0, Symbology = 1 << 1, Symbology3D = 1 << 2, Labeling = 1 << 3, Fields = 1 << 4, Forms = 1 << 5, Actions = 1 << 6, MapTips = 1 << 7, Diagrams = 1 << 8, AttributeTable = 1 << 9, Rendering = 1 << 10, CustomProperties = 1 << 11, GeometryOptions = 1 << 12, AllStyleCategories = LayerConfiguration | Symbology | Symbology3D | Labeling | Fields | Forms | Actions | MapTips | Diagrams | AttributeTable | Rendering | CustomProperties | GeometryOptions }
- Categories of style to distinguish appropriate sections for import/export.
Public static functions
- static auto extensionPropertyType(PropertyType type) -> QString
- Returns the extension of a Property.
- static auto formatLayerName(const QString& name) -> QString
- A convenience function to capitalize and format a layer name.
Constructors, destructors, conversion operators
-
QgsMapLayer(QgsMapLayer::
LayerType type = VectorLayer, const QString& name = QString(), const QString& source = QString()) - Constructor for QgsMapLayer.
- QgsMapLayer(QgsMapLayer const&) deleted
- QgsMapLayer cannot be copied.
Public functions
- auto abstract() const -> QString
- Returns the abstract of the layer used by QGIS Server in GetCapabilities request.
- auto attribution() const -> QString
- Returns the attribution of the layer used by QGIS Server in GetCapabilities request.
- auto attributionUrl() const -> QString
- Returns the attribution URL of the layer used by QGIS Server in GetCapabilities request.
- auto autoRefreshInterval() const -> int
- Returns the auto refresh interval (in milliseconds).
- auto blendMode() const -> QPainter::CompositionMode
- Returns the current blending mode for a layer.
- auto clone() const -> QgsMapLayer* pure virtual
- Returns a new instance equivalent to this one except for the id which is still unique.
- auto createMapRenderer(QgsRenderContext& rendererContext) -> QgsMapLayerRenderer* pure virtual
- Returns new instance of QgsMapLayerRenderer that will be used for rendering of given context.
- auto crs() const -> QgsCoordinateReferenceSystem
- Returns the layer's spatial reference system.
- auto customProperty(const QString& value, const QVariant& defaultValue = QVariant()) const -> QVariant
- Read a custom property from layer.
- auto customPropertyKeys() const -> QStringList
- Returns list of all keys within custom properties.
- auto dataProvider() -> QgsDataProvider* virtual
- Returns the layer's data provider, it may be null.
- auto dataProvider() const -> const QgsDataProvider* virtual
- Returns the layer's data provider in a const-correct manner, it may be null.
- auto dataUrl() const -> QString
- Returns the DataUrl of the layer used by QGIS Server in GetCapabilities request.
- auto dataUrlFormat() const -> QString
- Returns the DataUrl format of the layer used by QGIS Server in GetCapabilities request.
- auto dependencies() const -> QSet<QgsMapLayerDependency> virtual
- Gets the list of dependencies.
- auto error() const -> QgsError virtual
- Gets current status error.
- void exportNamedMetadata(QDomDocument& doc, QString& errorMsg) const
- Export the current metadata of this layer as named metadata in a QDomDocument.
-
void exportNamedStyle(QDomDocument& doc,
QString& errorMsg,
const QgsReadWriteContext& context = QgsReadWriteContext(),
QgsMapLayer::StyleCategories categories = QgsMapLayer::
AllStyleCategories) const virtual - Export the properties of this layer as named style in a QDomDocument.
- void exportSldStyle(QDomDocument& doc, QString& errorMsg) const virtual
- Export the properties of this layer as SLD style in a QDomDocument.
- auto extent() const -> QgsRectangle virtual
- Returns the extent of the layer.
- auto flags() const -> QgsMapLayer::LayerFlags
- Returns the flags for this layer.
- auto hasAutoRefreshEnabled() const -> bool
- Returns true if auto refresh is enabled for the layer.
- auto hasScaleBasedVisibility() const -> bool
- Returns whether scale based visibility is enabled for the layer.
- auto htmlMetadata() const -> QString virtual
- Obtain a formatted HTML string containing assorted metadata for this layer.
- auto id() const -> QString
- Returns the layer's unique ID, which is used to access this layer from QgsProject.
- auto importNamedMetadata(QDomDocument& document, QString& errorMessage) -> bool
- Import the metadata of this layer from a QDomDocument.
-
auto importNamedStyle(QDomDocument& doc,
QString& errorMsg,
QgsMapLayer::StyleCategories categories = QgsMapLayer::
AllStyleCategories) -> bool virtual - Import the properties of this layer from a QDomDocument.
- auto isEditable() const -> bool virtual
- Returns true if the layer can be edited.
- auto isInScaleRange(double scale) const -> bool
- Tests whether the layer should be visible at the specified scale.
- auto isRefreshOnNotifyEnabled() const -> bool
- Returns true if the refresh on provider nofification is enabled.
- auto isSpatial() const -> bool virtual
- Returns true if the layer is considered a spatial layer, ie it has some form of geometry associated with it.
- auto isValid() const -> bool
- Returns the status of the layer.
- auto keywordList() const -> QString
- Returns the keyword list of the layer used by QGIS Server in GetCapabilities request.
- auto legend() const -> QgsMapLayerLegend*
- Can be null.
- auto legendUrl() const -> QString
- Returns the URL for the layer's legend.
- auto legendUrlFormat() const -> QString
- Returns the format for a URL based layer legend.
- auto loadDefaultMetadata(bool& resultFlag) -> QString
- Retrieve the default metadata for this layer if one exists (either as a .qmd file on disk or as a record in the users metadata table in their personal qgis.db)
- auto loadDefaultStyle(bool& resultFlag) -> QString virtual
- Retrieve the default style for this layer if one exists (either as a .qml file on disk or as a record in the users style table in their personal qgis.db)
- auto loadNamedMetadata(const QString& uri, bool& resultFlag) -> QString virtual
- Retrieve a named metadata for this layer if one exists (either as a .qmd file on disk or as a record in the users style table in their personal qgis.db)
- auto loadNamedMetadataFromDatabase(const QString& db, const QString& uri, QString& qmd) -> bool
- Retrieve a named metadata for this layer from a sqlite database.
-
auto loadNamedStyle(const QString& uri,
bool& resultFlag,
QgsMapLayer::StyleCategories categories = QgsMapLayer::
AllStyleCategories) -> QString virtual - Retrieve a named style for this layer if one exists (either as a .qml file on disk or as a record in the users style table in their personal qgis.db)
- auto loadNamedStyleFromDatabase(const QString& db, const QString& uri, QString& qml) -> bool virtual
- Retrieve a named style for this layer from a sqlite database.
- auto loadSldStyle(const QString& uri, bool& resultFlag) -> QString virtual
- Attempts to style the layer using the formatting from an SLD type file.
- auto maximumScale() const -> double
- Returns the maximum map scale (i.e.
- auto metadata() const -> const QgsLayerMetadata& virtual
- Returns a reference to the layer's metadata store.
- auto metadataUri() const -> QString virtual
- Retrieve the metadata URI for this layer (either as a .qmd file on disk or as a record in the users style table in their personal qgis.db)
- auto metadataUrl() const -> QString
- Returns the metadata URL of the layer used by QGIS Server in GetCapabilities request.
- auto metadataUrlFormat() const -> QString
- Returns the metadata format of the layer used by QGIS Server in GetCapabilities request.
- auto metadataUrlType() const -> QString
- Returns the metadata type of the layer used by QGIS Server in GetCapabilities request.
- auto minimumScale() const -> double
- Returns the minimum map scale (i.e.
- auto name() const -> QString
- Returns the display name of the layer.
- auto operator=(QgsMapLayer const&) -> QgsMapLayer& deleted
- QgsMapLayer cannot be copied.
- auto originalXmlProperties() const -> QString
- Returns the XML properties of the original layer as they were when the layer was first read from the project file.
- auto providerType() const -> QString
- Returns the provider type (provider key) for this layer.
- auto publicSource() const -> QString
- Gets a version of the internal layer definition that has sensitive bits removed (for example, the password).
- auto readLayerXml(const QDomElement& layerElement, QgsReadWriteContext& context) -> bool
- Sets state from DOM document.
- auto readOnly() const -> bool
- Returns if this layer is read only.
- auto readStyle(const QDomNode& node, QString& errorMessage, QgsReadWriteContext& context, StyleCategories categories = AllStyleCategories) -> bool virtual
- Read the style for the current layer from the DOM node supplied.
- auto readSymbology(const QDomNode& node, QString& errorMessage, QgsReadWriteContext& context, StyleCategories categories = AllStyleCategories) -> bool pure virtual
- Read the symbology for the current layer from the DOM node supplied.
- auto refreshOnNotifyMessage() const -> QString
- Returns the message that should be notified by the provider to triggerRepaint.
- void reload() virtual
- Synchronises with changes in the datasource.
- void removeCustomProperty(const QString& key)
- Remove a custom property from layer.
- auto renderer3D() const -> QgsAbstract3DRenderer*
- Returns 3D renderer associated with the layer.
- void resolveReferences(QgsProject* project) virtual
- Resolve references to other layers (kept as layer IDs after reading XML) into layer objects.
- auto saveDefaultMetadata(bool& resultFlag) -> QString virtual
- Save the current metadata of this layer as the default metadata (either as a .qmd file on disk or as a record in the users style table in their personal qgis.db)
- auto saveDefaultStyle(bool& resultFlag) -> QString virtual
- Save the properties of this layer as the default style (either as a .qml file on disk or as a record in the users style table in their personal qgis.db)
- auto saveNamedMetadata(const QString& uri, bool& resultFlag) -> QString
- Save the current metadata of this layer as a named metadata (either as a .qmd file on disk or as a record in the users style table in their personal qgis.db)
- auto saveNamedStyle(const QString& uri, bool& resultFlag, StyleCategories categories = AllStyleCategories) -> QString virtual
- Save the properties of this layer as a named style (either as a .qml file on disk or as a record in the users style table in their personal qgis.db)
- auto saveSldStyle(const QString& uri, bool& resultFlag) const -> QString virtual
- Saves the properties of this layer to an SLD format file.
- void setAbstract(const QString& abstract)
- Sets the abstract of the layer used by QGIS Server in GetCapabilities request.
- void setAttribution(const QString& attrib)
- Sets the attribution of the layer used by QGIS Server in GetCapabilities request.
- void setAttributionUrl(const QString& attribUrl)
- Sets the attribution URL of the layer used by QGIS Server in GetCapabilities request.
- void setAutoRefreshEnabled(bool enabled)
- Sets whether auto refresh is enabled for the layer.
- void setAutoRefreshInterval(int interval)
- Sets the auto refresh interval (in milliseconds) for the layer.
- void setBlendMode(QPainter::CompositionMode blendMode)
- Set the blending mode used for rendering a layer.
- void setCrs(const QgsCoordinateReferenceSystem& srs, bool emitSignal = true)
- Sets layer's spatial reference system.
- void setCustomProperties(const QgsObjectCustomProperties& properties)
- Set custom properties for layer.
- void setCustomProperty(const QString& key, const QVariant& value)
- Set a custom property for layer.
-
void setDataSource(const QString& dataSource,
const QString& baseName,
const QString& provider,
const QgsDataProvider::
ProviderOptions& options, bool loadDefaultStyleFlag = false) virtual - Updates the data source of the layer.
- void setDataUrl(const QString& dataUrl)
- Sets the DataUrl of the layer used by QGIS Server in GetCapabilities request.
- void setDataUrlFormat(const QString& dataUrlFormat)
- Sets the DataUrl format of the layer used by QGIS Server in GetCapabilities request.
- void setFlags(QgsMapLayer::LayerFlags flags)
- Returns the flags for this layer.
- void setKeywordList(const QString& keywords)
- Sets the keyword list of the layer used by QGIS Server in GetCapabilities request.
- void setLayerOrder(const QStringList& layers) virtual
- Reorders the previously selected sublayers of this layer from bottom to top.
- void setLegend(QgsMapLayerLegend* legend)
- Assign a legend controller to the map layer.
- void setLegendUrl(const QString& legendUrl)
- Sets the URL for the layer's legend.
- void setLegendUrlFormat(const QString& legendUrlFormat)
- Sets the format for a URL based layer legend.
- void setMetadata(const QgsLayerMetadata& metadata) virtual
- Sets the layer's metadata store.
- void setMetadataUrl(const QString& metaUrl)
- Sets the metadata URL of the layer used by QGIS Server in GetCapabilities request.
- void setMetadataUrlFormat(const QString& metaUrlFormat)
- Sets the metadata format of the layer used by QGIS Server in GetCapabilities request.
- void setMetadataUrlType(const QString& metaUrlType)
- Set the metadata type of the layer used by QGIS Server in GetCapabilities request MetadataUrlType indicates the standard to which the metadata complies.
- void setName(const QString& name)
- Set the display name of the layer.
- void setOriginalXmlProperties(const QString& originalXmlProperties)
- Sets the original XML properties for the layer to originalXmlProperties.
- void setRenderer3D(QgsAbstract3DRenderer* renderer)
- Sets 3D renderer for the layer.
- void setShortName(const QString& shortName)
- Sets the short name of the layer used by QGIS Server to identify the layer.
- void setSubLayerVisibility(const QString& name, bool visible) virtual
- Set the visibility of the given sublayer name.
- void setTitle(const QString& title)
- Sets the title of the layer used by QGIS Server in GetCapabilities request.
- auto shortName() const -> QString
- Returns the short name of the layer used by QGIS Server to identify the layer.
- auto source() const -> QString
- Returns the source for the layer.
- auto styleManager() const -> QgsMapLayerStyleManager*
- Gets access to the layer's style manager.
- auto styleURI() const -> QString virtual
- Retrieve the style URI for this layer (either as a .qml file on disk or as a record in the users style table in their personal qgis.db)
- auto subLayers() const -> QStringList virtual
- Returns the sublayers of this layer.
- auto timestamp() const -> QDateTime virtual
- Time stamp of data source in the moment when data/metadata were loaded by provider.
- auto title() const -> QString
- Returns the title of the layer used by QGIS Server in GetCapabilities request.
-
auto type() const -> QgsMapLayer::
LayerType - Returns the type of the layer.
- auto undoStack() -> QUndoStack*
- Returns pointer to layer's undo stack.
- auto undoStackStyles() -> QUndoStack*
- Returns pointer to layer's style undo stack.
- auto writeLayerXml(QDomElement& layerElement, QDomDocument& document, const QgsReadWriteContext& context) const -> bool
- Stores state in DOM node.
- auto writeStyle(QDomNode& node, QDomDocument& doc, QString& errorMessage, const QgsReadWriteContext& context, StyleCategories categories = AllStyleCategories) const -> bool virtual
- Write just the symbology information for the layer into the document.
- auto writeSymbology(QDomNode& node, QDomDocument& doc, QString& errorMessage, const QgsReadWriteContext& context, StyleCategories categories = AllStyleCategories) const -> bool pure virtual
- Write the style for the layer into the docment provided.
Signals
- void autoRefreshIntervalChanged(int interval)
- Emitted when the auto refresh interval changes.
- void blendModeChanged(QPainter::CompositionMode blendMode)
- Signal emitted when the blend mode is changed, through QgsMapLayer::
setBlendMode() - void configChanged()
- Emitted whenever the configuration is changed.
- void crsChanged()
- Emit a signal that layer's CRS has been reset.
- void dataChanged()
- Data of layer changed.
- void dataSourceChanged()
- Emitted whenever the layer's data source has been changed.
- void dependenciesChanged()
- Emitted when dependencies are changed.
- void flagsChanged()
- Emitted when layer's flags have been modified.
- void legendChanged()
- Signal emitted when legend of the layer has changed.
- void metadataChanged()
- Emitted when the layer's metadata is changed.
- void nameChanged()
- Emitted when the name has been changed.
- void recalculateExtents() const
- This is used to send a request that any mapcanvas using this layer update its extents.
- void renderer3DChanged()
- Signal emitted when 3D renderer associated with the layer has changed.
- void rendererChanged()
- Signal emitted when renderer is changed.
- void repaintRequested(bool deferredUpdate = false)
- By emitting this signal the layer tells that either appearance or content have been changed and any view showing the rendered layer should refresh itself.
- void statusChanged(const QString& status)
- Emit a signal with status (e.g. to be caught by QgisApp and display a msg on status bar)
- void styleChanged()
- Signal emitted whenever a change affects the layer's style.
- void willBeDeleted()
- Emitted in the destructor when the layer is about to be deleted, but it is still in a perfectly valid state: the last chance for other pieces of code for some cleanup if they use the layer.
Public slots
- void emitStyleChanged()
- Triggers an emission of the styleChanged() signal.
- auto setDependencies(const QSet<QgsMapLayerDependency>& layers) -> bool virtual
- Sets the list of dependencies.
- void setMaximumScale(double scale)
- Sets the maximum map scale (i.e.
- void setMinimumScale(double scale)
- Sets the minimum map scale (i.e.
- void setRefreshOnNofifyMessage(const QString& message)
- Set the notification message that triggers repaine If refresh on notification is enabled, the notification will triggerRepaint only if the notification message is equal to.
- void setRefreshOnNotifyEnabled(bool enabled)
- Set whether provider notification is connected to triggerRepaint.
- void setScaleBasedVisibility(bool enabled)
- Sets whether scale based visibility is enabled for the layer.
- void triggerRepaint(bool deferredUpdate = false)
- Will advise the map canvas (and any other interested party) that this layer requires to be repainted.
Protected functions
- void appendError(const QgsErrorMessage& error)
- Add error message.
- void clone(QgsMapLayer* layer) const
- Copies attributes like name, short name, ...
- auto decodedSource(const QString& source, const QString& dataProvider, const QgsReadWriteContext& context) const -> QString virtual
- Called by readLayerXML(), used by derived classes to decode provider's specific data source from project files.
- auto encodedSource(const QString& source, const QgsReadWriteContext& context) const -> QString virtual
- Called by writeLayerXML(), used by derived classes to encode provider's specific data source to project files.
- auto hasDependencyCycle(const QSet<QgsMapLayerDependency>& layers) const -> bool
- Checks whether a new set of dependencies will introduce a cycle.
- void readCommonStyle(const QDomElement& layerElement, const QgsReadWriteContext& context, StyleCategories categories = AllStyleCategories)
- Read style data common to all layer types.
- void readCustomProperties(const QDomNode& layerNode, const QString& keyStartsWith = QString())
- Read custom properties from project file.
- void readStyleManager(const QDomNode& layerNode)
- Read style manager's configuration (if any). To be called by subclasses.
- auto readXml(const QDomNode& layer_node, QgsReadWriteContext& context) -> bool virtual
- Called by readLayerXML(), used by children to read state specific to them from project files.
- void setError(const QgsError& error)
- Sets error message.
- void setExtent(const QgsRectangle& rect) virtual
- Sets the extent.
- void setProviderType(const QString& providerType)
- Sets the providerType (provider key)
- void setValid(bool valid)
- Sets whether layer is valid or not - should be used in constructor.
- void writeCommonStyle(QDomElement& layerElement, QDomDocument& document, const QgsReadWriteContext& context, StyleCategories categories = AllStyleCategories) const
- Write style data common to all layer types.
- void writeCustomProperties(QDomNode& layerNode, QDomDocument& doc) const
- Write custom properties to project file.
- void writeStyleManager(QDomNode& layerNode, QDomDocument& doc) const
- Write style manager's configuration (if exists). To be called by subclasses.
- auto writeXml(QDomNode& layer_node, QDomDocument& document, const QgsReadWriteContext& context) const -> bool virtual
- Called by writeLayerXML(), used by children to write state specific to them to project files.
Protected variables
- QString mAbstract
- Description of the layer.
- QString mAttribution
- Attribution of the layer.
- QString mDataSource
- Data source description string, varies by layer type.
- QString mDataUrl
- DataUrl of the layer.
- QSet<QgsMapLayerDependency> mDependencies
- List of layers that may modify this layer on modification.
- QgsError mError
- Error.
- QgsRectangle mExtent
- Extent of the layer.
- QString mLayerName
- Name of the layer - used for display.
- QString mLegendUrl
- WMS legend.
- QString mMetadataUrl
- MetadataUrl of the layer.
- QString mProviderKey
- Data provider key (name of the data provider)
- bool mValid
- Indicates if the layer is valid and can be drawn.
Private functions
- auto isReadOnly() const -> bool virtual
- This method returns true by default but can be overwritten to specify that a certain layer is writable.
Enum documentation
enum QgsMapLayer:: LayerFlag
Flags for the map layer.
| Enumerators | |
|---|---|
| Identifiable |
If the layer is identifiable using the identify map tool and as a WMS layer. |
| Removable |
If the layer can be removed from the project. The layer will not be removable from the legend menu entry but can still be removed with an API call. |
| Searchable |
Only for vector-layer, determines if the layer is used in the 'search all layers' locator. |
enum QgsMapLayer:: LayerType
Types of layers that can be added to a map.
| Enumerators | |
|---|---|
| VectorLayer | |
| RasterLayer | |
| PluginLayer | |
| MeshLayer |
Added in 3.2. |
enum QgsMapLayer:: PropertyType
Maplayer has a style and a metadata property.
enum QgsMapLayer:: StyleCategory
Categories of style to distinguish appropriate sections for import/export.
| Enumerators | |
|---|---|
| LayerConfiguration |
General configuration: identifiable, removable, searchable, display expression, read-only. |
| Symbology |
Symbology. |
| Symbology3D |
3D symbology |
| Labeling |
Labeling. |
| Fields |
Aliases, widgets, WMS/WFS, expressions, constraints, virtual fields. |
| Forms |
Feature form. |
| Actions |
Actions. |
| MapTips |
Map tips. |
| Diagrams |
Diagrams. |
| AttributeTable |
Attribute table settings: choice and order of columns, conditional styling. |
| Rendering |
Rendering: scale visibility, simplify method, opacity. |
| CustomProperties |
Custom properties (by plugins for instance) |
| GeometryOptions |
Geometry validation configuration. |
| AllStyleCategories |
Function documentation
static QString QgsMapLayer:: extensionPropertyType(PropertyType type)
Returns the extension of a Property.
| Returns | The extension |
|---|
static QString QgsMapLayer:: formatLayerName(const QString& name)
A convenience function to capitalize and format a layer name.
QgsMapLayer:: QgsMapLayer(QgsMapLayer:: LayerType type = VectorLayer,
const QString& name = QString(),
const QString& source = QString())
Constructor for QgsMapLayer.
| Parameters | |
|---|---|
| type | layer type |
| name | display name for the layer |
| source | datasource of layer |
QString QgsMapLayer:: abstract() const
Returns the abstract of the layer used by QGIS Server in GetCapabilities request.
| Returns | the layer abstract |
|---|
QString QgsMapLayer:: attribution() const
Returns the attribution of the layer used by QGIS Server in GetCapabilities request.
| Returns | the layer attribution |
|---|
Attribution indicates the provider of a layer or collection of layers.
QString QgsMapLayer:: attributionUrl() const
Returns the attribution URL of the layer used by QGIS Server in GetCapabilities request.
| Returns | the layer attribution URL |
|---|
Attribution indicates the provider of a layer or collection of layers.
int QgsMapLayer:: autoRefreshInterval() const
Returns the auto refresh interval (in milliseconds).
Note that auto refresh is only active when hasAutoRefreshEnabled() is true.
QPainter::CompositionMode QgsMapLayer:: blendMode() const
Returns the current blending mode for a layer.
QgsMapLayer* QgsMapLayer:: clone() const pure virtual
Returns a new instance equivalent to this one except for the id which is still unique.
| Returns | a new layer instance |
|---|
QgsMapLayerRenderer* QgsMapLayer:: createMapRenderer(QgsRenderContext& rendererContext) pure virtual
Returns new instance of QgsMapLayerRenderer that will be used for rendering of given context.
QgsCoordinateReferenceSystem QgsMapLayer:: crs() const
Returns the layer's spatial reference system.
QVariant QgsMapLayer:: customProperty(const QString& value,
const QVariant& defaultValue = QVariant()) const
Read a custom property from layer.
Properties are stored in a map and saved in project file.
QStringList QgsMapLayer:: customPropertyKeys() const
Returns list of all keys within custom properties.
Properties are stored in a map and saved in project file.
const QgsDataProvider* QgsMapLayer:: dataProvider() const virtual
Returns the layer's data provider in a const-correct manner, it may be null.
QString QgsMapLayer:: dataUrl() const
Returns the DataUrl of the layer used by QGIS Server in GetCapabilities request.
| Returns | the layer DataUrl |
|---|
DataUrl is a a link to the underlying data represented by a particular layer.
QString QgsMapLayer:: dataUrlFormat() const
Returns the DataUrl format of the layer used by QGIS Server in GetCapabilities request.
| Returns | the layer DataUrl format |
|---|
DataUrl is a a link to the underlying data represented by a particular layer.
QSet<QgsMapLayerDependency> QgsMapLayer:: dependencies() const virtual
Gets the list of dependencies.
| Returns | a set of QgsMapLayerDependency |
|---|
This includes data dependencies set by the user (
void QgsMapLayer:: exportNamedMetadata(QDomDocument& doc,
QString& errorMsg) const
Export the current metadata of this layer as named metadata in a QDomDocument.
| Parameters | |
|---|---|
| doc | the target QDomDocument |
| errorMsg | this QString will be initialized on error |
void QgsMapLayer:: exportNamedStyle(QDomDocument& doc,
QString& errorMsg,
const QgsReadWriteContext& context = QgsReadWriteContext(),
QgsMapLayer::StyleCategories categories = QgsMapLayer:: AllStyleCategories) const virtual
Export the properties of this layer as named style in a QDomDocument.
| Parameters | |
|---|---|
| doc | the target QDomDocument |
| errorMsg | this QString will be initialized on error |
| context | read write context |
| categories | the style categories to export during the execution of writeSymbology |
void QgsMapLayer:: exportSldStyle(QDomDocument& doc,
QString& errorMsg) const virtual
Export the properties of this layer as SLD style in a QDomDocument.
| Parameters | |
|---|---|
| doc | the target QDomDocument |
| errorMsg | this QString will be initialized on error during the execution of writeSymbology |
QgsMapLayer::LayerFlags QgsMapLayer:: flags() const
Returns the flags for this layer.
bool QgsMapLayer:: hasAutoRefreshEnabled() const
Returns true if auto refresh is enabled for the layer.
bool QgsMapLayer:: hasScaleBasedVisibility() const
Returns whether scale based visibility is enabled for the layer.
| Returns | true if scale based visibility is enabled |
|---|
QString QgsMapLayer:: htmlMetadata() const virtual
Obtain a formatted HTML string containing assorted metadata for this layer.
bool QgsMapLayer:: importNamedMetadata(QDomDocument& document,
QString& errorMessage)
Import the metadata of this layer from a QDomDocument.
| Parameters | |
|---|---|
| document | source QDomDocument |
| errorMessage | this QString will be initialized on error |
| Returns | true on success |
bool QgsMapLayer:: importNamedStyle(QDomDocument& doc,
QString& errorMsg,
QgsMapLayer::StyleCategories categories = QgsMapLayer:: AllStyleCategories) virtual
Import the properties of this layer from a QDomDocument.
| Parameters | |
|---|---|
| doc | source QDomDocument |
| errorMsg | this QString will be initialized on error during the execution of readSymbology |
| categories | the style categories to import |
| Returns | true on success |
bool QgsMapLayer:: isInScaleRange(double scale) const
Tests whether the layer should be visible at the specified scale.
| Returns | true if the layer is visible at the given scale. |
|---|
The scale value indicates the scale denominator, e.g. 1000.0 for a 1:1000 map.
bool QgsMapLayer:: isRefreshOnNotifyEnabled() const
Returns true if the refresh on provider nofification is enabled.
bool QgsMapLayer:: isSpatial() const virtual
Returns true if the layer is considered a spatial layer, ie it has some form of geometry associated with it.
bool QgsMapLayer:: isValid() const
Returns the status of the layer.
| Returns | true if the layer is valid and can be accessed |
|---|
An invalid layer is one which has a bad datasource or other problem. Child classes set this flag when initialized.
QString QgsMapLayer:: keywordList() const
Returns the keyword list of the layer used by QGIS Server in GetCapabilities request.
| Returns | the layer keyword list |
|---|
QgsMapLayerLegend* QgsMapLayer:: legend() const
Can be null.
QString QgsMapLayer:: loadDefaultMetadata(bool& resultFlag)
Retrieve the default metadata for this layer if one exists (either as a .qmd file on disk or as a record in the users metadata table in their personal qgis.db)
| Parameters | |
|---|---|
| resultFlag | a reference to a flag that will be set to false if we did not manage to load the default metadata. |
| Returns | a QString with any status messages |
QString QgsMapLayer:: loadDefaultStyle(bool& resultFlag) virtual
Retrieve the default style for this layer if one exists (either as a .qml file on disk or as a record in the users style table in their personal qgis.db)
| Parameters | |
|---|---|
| resultFlag | a reference to a flag that will be set to false if we did not manage to load the default style. |
| Returns | a QString with any status messages |
QString QgsMapLayer:: loadNamedMetadata(const QString& uri,
bool& resultFlag) virtual
Retrieve a named metadata for this layer if one exists (either as a .qmd file on disk or as a record in the users style table in their personal qgis.db)
| Parameters | |
|---|---|
| uri | - the file name or other URI for the metadata file. First an attempt will be made to see if this is a file and load that, if that fails the qgis.db metadata table will be consulted to see if there is a metadata who's key matches the URI. |
| resultFlag | a reference to a flag that will be set to false if we did not manage to load the default metadata. |
| Returns | a QString with any status messages |
bool QgsMapLayer:: loadNamedMetadataFromDatabase(const QString& db,
const QString& uri,
QString& qmd)
Retrieve a named metadata for this layer from a sqlite database.
| Parameters | |
|---|---|
| db | path to sqlite database |
| uri | uri for table |
| qmd | will be set to QMD xml metadata content from database |
| Returns | true if style was successfully loaded |
QString QgsMapLayer:: loadNamedStyle(const QString& uri,
bool& resultFlag,
QgsMapLayer::StyleCategories categories = QgsMapLayer:: AllStyleCategories) virtual
Retrieve a named style for this layer if one exists (either as a .qml file on disk or as a record in the users style table in their personal qgis.db)
| Parameters | |
|---|---|
| uri | - the file name or other URI for the style file. First an attempt will be made to see if this is a file and load that, if that fails the qgis.db styles table will be consulted to see if there is a style who's key matches the URI. |
| resultFlag | a reference to a flag that will be set to false if we did not manage to load the default style. |
| categories | the style categories to be loaded. |
| Returns | a QString with any status messages |
bool QgsMapLayer:: loadNamedStyleFromDatabase(const QString& db,
const QString& uri,
QString& qml) virtual
Retrieve a named style for this layer from a sqlite database.
| Parameters | |
|---|---|
| db | path to sqlite database |
| uri | uri for table |
| qml | will be set to QML style content from database |
| Returns | true if style was successfully loaded |
QString QgsMapLayer:: loadSldStyle(const QString& uri,
bool& resultFlag) virtual
Attempts to style the layer using the formatting from an SLD type file.
| Parameters | |
|---|---|
| uri | uri of source SLD file |
| resultFlag | a reference to a flag that will be set to false if the SLD file could not be loaded |
| Returns | a string with any status or error messages |
double QgsMapLayer:: maximumScale() const
Returns the maximum map scale (i.e.
most "zoomed in" scale) at which the layer will be visible. The scale value indicates the scale denominator, e.g. 1000.0 for a 1:1000 map. A scale of 0 indicates no maximum scale visibility.
const QgsLayerMetadata& QgsMapLayer:: metadata() const virtual
Returns a reference to the layer's metadata store.
QString QgsMapLayer:: metadataUri() const virtual
Retrieve the metadata URI for this layer (either as a .qmd file on disk or as a record in the users style table in their personal qgis.db)
| Returns | a QString with the metadata file name |
|---|
QString QgsMapLayer:: metadataUrl() const
Returns the metadata URL of the layer used by QGIS Server in GetCapabilities request.
| Returns | the layer metadata URL |
|---|
MetadataUrl is a a link to the detailed, standardized metadata about the data.
QString QgsMapLayer:: metadataUrlFormat() const
Returns the metadata format of the layer used by QGIS Server in GetCapabilities request.
| Returns | the layer metadata format |
|---|
MetadataUrlType indicates how the metadata is structured.
QString QgsMapLayer:: metadataUrlType() const
Returns the metadata type of the layer used by QGIS Server in GetCapabilities request.
| Returns | the layer metadata type |
|---|
MetadataUrlType indicates the standard to which the metadata complies.
double QgsMapLayer:: minimumScale() const
Returns the minimum map scale (i.e.
most "zoomed out" scale) at which the layer will be visible. The scale value indicates the scale denominator, e.g. 1000.0 for a 1:1000 map. A scale of 0 indicates no minimum scale visibility.
QString QgsMapLayer:: name() const
Returns the display name of the layer.
QString QgsMapLayer:: originalXmlProperties() const
Returns the XML properties of the original layer as they were when the layer was first read from the project file.
In case of new layers this is normally empty.
The storage format for the XML is qlr
QString QgsMapLayer:: publicSource() const
Gets a version of the internal layer definition that has sensitive bits removed (for example, the password).
This function should be used when displaying the source name for general viewing.
bool QgsMapLayer:: readLayerXml(const QDomElement& layerElement,
QgsReadWriteContext& context)
Sets state from DOM document.
| Parameters | |
|---|---|
| layerElement | The DOM element corresponding to ``maplayer'' tag |
| context | writing context (e.g. for conversion between relative and absolute paths) |
| Returns | true if successful |
The DOM node corresponds to a DOM document project file XML element read by QgsProject.
This, in turn, calls readXml() (and then readSymbology()), which is overridable by sub-classes so that they can read their own specific state from the given DOM node.
Invoked by QgsProject::
bool QgsMapLayer:: readStyle(const QDomNode& node,
QString& errorMessage,
QgsReadWriteContext& context,
StyleCategories categories = AllStyleCategories) virtual
Read the style for the current layer from the DOM node supplied.
| Parameters | |
|---|---|
| node | node that will contain the style definition for this layer. |
| errorMessage | reference to string that will be updated with any error messages |
| context | reading context (used for transform from relative to absolute paths) |
| categories | the style categories to be read |
| Returns | true in case of success. |
bool QgsMapLayer:: readSymbology(const QDomNode& node,
QString& errorMessage,
QgsReadWriteContext& context,
StyleCategories categories = AllStyleCategories) pure virtual
Read the symbology for the current layer from the DOM node supplied.
| Parameters | |
|---|---|
| node | node that will contain the symbology definition for this layer. |
| errorMessage | reference to string that will be updated with any error messages |
| context | reading context (used for transform from relative to absolute paths) |
| categories | the style categories to be read |
| Returns | true in case of success. |
QString QgsMapLayer:: refreshOnNotifyMessage() const
Returns the message that should be notified by the provider to triggerRepaint.
void QgsMapLayer:: removeCustomProperty(const QString& key)
Remove a custom property from layer.
Properties are stored in a map and saved in project file.
QgsAbstract3DRenderer* QgsMapLayer:: renderer3D() const
Returns 3D renderer associated with the layer.
May be null.
void QgsMapLayer:: resolveReferences(QgsProject* project) virtual
Resolve references to other layers (kept as layer IDs after reading XML) into layer objects.
QString QgsMapLayer:: saveDefaultMetadata(bool& resultFlag) virtual
Save the current metadata of this layer as the default metadata (either as a .qmd file on disk or as a record in the users style table in their personal qgis.db)
| Parameters | |
|---|---|
| resultFlag | a reference to a flag that will be set to false if we did not manage to save the default metadata. |
| Returns | a QString with any status messages |
QString QgsMapLayer:: saveDefaultStyle(bool& resultFlag) virtual
Save the properties of this layer as the default style (either as a .qml file on disk or as a record in the users style table in their personal qgis.db)
| Parameters | |
|---|---|
| resultFlag | a reference to a flag that will be set to false if we did not manage to save the default style. |
| Returns | a QString with any status messages |
QString QgsMapLayer:: saveNamedMetadata(const QString& uri,
bool& resultFlag)
Save the current metadata of this layer as a named metadata (either as a .qmd file on disk or as a record in the users style table in their personal qgis.db)
| Parameters | |
|---|---|
| uri | the file name or other URI for the metadata file. First an attempt will be made to see if this is a file and save to that, if that fails the qgis.db metadata table will be used to create a metadata entry who's key matches the URI. |
| resultFlag | a reference to a flag that will be set to false if we did not manage to save the default metadata. |
| Returns | a QString with any status messages |
QString QgsMapLayer:: saveNamedStyle(const QString& uri,
bool& resultFlag,
StyleCategories categories = AllStyleCategories) virtual
Save the properties of this layer as a named style (either as a .qml file on disk or as a record in the users style table in their personal qgis.db)
| Parameters | |
|---|---|
| uri | the file name or other URI for the style file. First an attempt will be made to see if this is a file and save to that, if that fails the qgis.db styles table will be used to create a style entry who's key matches the URI. |
| resultFlag | a reference to a flag that will be set to false if we did not manage to save the default style. |
| categories | the style categories to be saved. |
| Returns | a QString with any status messages |
QString QgsMapLayer:: saveSldStyle(const QString& uri,
bool& resultFlag) const virtual
Saves the properties of this layer to an SLD format file.
| Parameters | |
|---|---|
| uri | uri of destination for exported SLD file. |
| resultFlag | a reference to a flag that will be set to false if the SLD file could not be generated |
| Returns | a string with any status or error messages |
void QgsMapLayer:: setAbstract(const QString& abstract)
Sets the abstract of the layer used by QGIS Server in GetCapabilities request.
| Returns | the layer abstract |
|---|
void QgsMapLayer:: setAttribution(const QString& attrib)
Sets the attribution of the layer used by QGIS Server in GetCapabilities request.
| Returns | the layer attribution |
|---|
Attribution indicates the provider of a layer or collection of layers.
void QgsMapLayer:: setAttributionUrl(const QString& attribUrl)
Sets the attribution URL of the layer used by QGIS Server in GetCapabilities request.
| Returns | the layer attribution URL |
|---|
Attribution indicates the provider of a layer or collection of layers.
void QgsMapLayer:: setAutoRefreshEnabled(bool enabled)
Sets whether auto refresh is enabled for the layer.
void QgsMapLayer:: setAutoRefreshInterval(int interval)
Sets the auto refresh interval (in milliseconds) for the layer.
This will cause the layer to be automatically redrawn on a matching interval. Note that auto refresh must be enabled by calling setAutoRefreshEnabled().
Note that auto refresh triggers deferred repaints of the layer. Any map canvas must be refreshed separately in order to view the refreshed layer.
void QgsMapLayer:: setBlendMode(QPainter::CompositionMode blendMode)
Set the blending mode used for rendering a layer.
| Parameters | |
|---|---|
| blendMode | new blending mode |
void QgsMapLayer:: setCustomProperties(const QgsObjectCustomProperties& properties)
Set custom properties for layer.
Current properties are dropped.
void QgsMapLayer:: setCustomProperty(const QString& key,
const QVariant& value)
Set a custom property for layer.
Properties are stored in a map and saved in project file.
void QgsMapLayer:: setDataSource(const QString& dataSource,
const QString& baseName,
const QString& provider,
const QgsDataProvider:: ProviderOptions& options,
bool loadDefaultStyleFlag = false) virtual
Updates the data source of the layer.
| Parameters | |
|---|---|
| dataSource | new layer data source |
| baseName | base name of the layer |
| provider | provider string |
| options | provider options |
| loadDefaultStyleFlag | set to true to reset the layer's style to the default for the data source |
The layer's renderer and legend will be preserved only if the geometry type of the new data source matches the current geometry type of the layer.
Subclasses should override this method: default implementation does nothing.
void QgsMapLayer:: setDataUrl(const QString& dataUrl)
Sets the DataUrl of the layer used by QGIS Server in GetCapabilities request.
| Returns | the layer DataUrl |
|---|
DataUrl is a a link to the underlying data represented by a particular layer.
void QgsMapLayer:: setDataUrlFormat(const QString& dataUrlFormat)
Sets the DataUrl format of the layer used by QGIS Server in GetCapabilities request.
| Returns | the layer DataUrl format |
|---|
DataUrl is a a link to the underlying data represented by a particular layer.
void QgsMapLayer:: setFlags(QgsMapLayer::LayerFlags flags)
Returns the flags for this layer.
void QgsMapLayer:: setKeywordList(const QString& keywords)
Sets the keyword list of the layer used by QGIS Server in GetCapabilities request.
| Returns | the layer keyword list |
|---|
void QgsMapLayer:: setLayerOrder(const QStringList& layers) virtual
Reorders the previously selected sublayers of this layer from bottom to top.
(Useful for providers that manage their own layers, such as WMS).
void QgsMapLayer:: setLegend(QgsMapLayerLegend* legend)
Assign a legend controller to the map layer.
| Parameters | |
|---|---|
| legend | Takes ownership of the object. Can be null pointer |
The object will be responsible for providing legend items.
void QgsMapLayer:: setMetadata(const QgsLayerMetadata& metadata) virtual
Sets the layer's metadata store.
void QgsMapLayer:: setMetadataUrl(const QString& metaUrl)
Sets the metadata URL of the layer used by QGIS Server in GetCapabilities request.
| Returns | the layer metadata URL |
|---|
MetadataUrl is a a link to the detailed, standardized metadata about the data.
void QgsMapLayer:: setMetadataUrlFormat(const QString& metaUrlFormat)
Sets the metadata format of the layer used by QGIS Server in GetCapabilities request.
| Returns | the layer metadata format |
|---|
MetadataUrlType indicates how the metadata is structured.
void QgsMapLayer:: setMetadataUrlType(const QString& metaUrlType)
Set the metadata type of the layer used by QGIS Server in GetCapabilities request MetadataUrlType indicates the standard to which the metadata complies.
| Returns | the layer metadata type |
|---|
void QgsMapLayer:: setName(const QString& name)
Set the display name of the layer.
void QgsMapLayer:: setOriginalXmlProperties(const QString& originalXmlProperties)
Sets the original XML properties for the layer to originalXmlProperties.
The storage format for the XML is qlr
void QgsMapLayer:: setRenderer3D(QgsAbstract3DRenderer* renderer)
Sets 3D renderer for the layer.
Takes ownership of the renderer.
void QgsMapLayer:: setShortName(const QString& shortName)
Sets the short name of the layer used by QGIS Server to identify the layer.
| Returns | the layer short name |
|---|
void QgsMapLayer:: setSubLayerVisibility(const QString& name,
bool visible) virtual
Set the visibility of the given sublayer name.
| Parameters | |
|---|---|
| name | sublayer name |
| visible | sublayer visibility |
void QgsMapLayer:: setTitle(const QString& title)
Sets the title of the layer used by QGIS Server in GetCapabilities request.
QString QgsMapLayer:: shortName() const
Returns the short name of the layer used by QGIS Server to identify the layer.
QString QgsMapLayer:: source() const
Returns the source for the layer.
This source may contain usernames, passwords and other sensitive information.
QgsMapLayerStyleManager* QgsMapLayer:: styleManager() const
Gets access to the layer's style manager.
Style manager allows switching between multiple styles.
QString QgsMapLayer:: styleURI() const virtual
Retrieve the style URI for this layer (either as a .qml file on disk or as a record in the users style table in their personal qgis.db)
| Returns | a QString with the style file name |
|---|
QStringList QgsMapLayer:: subLayers() const virtual
Returns the sublayers of this layer.
(Useful for providers that manage their own layers, such as WMS).
QString QgsMapLayer:: title() const
Returns the title of the layer used by QGIS Server in GetCapabilities request.
| Returns | the layer title |
|---|
QUndoStack* QgsMapLayer:: undoStackStyles()
Returns pointer to layer's style undo stack.
bool QgsMapLayer:: writeLayerXml(QDomElement& layerElement,
QDomDocument& document,
const QgsReadWriteContext& context) const
Stores state in DOM node.
| Parameters | |
|---|---|
| layerElement | is a DOM element corresponding to ``maplayer'' tag |
| document | is a the DOM document being written |
| context | reading context (e.g. for conversion between relative and absolute paths) |
| Returns | true if successful |
The DOM node corresponds to a DOM document project file XML element to be written by QgsProject.
This, in turn, calls writeXml() (and then writeSymbology), which is over-rideable by sub-classes so that they can write their own specific state to the given DOM node.
Invoked by QgsProject::
bool QgsMapLayer:: writeStyle(QDomNode& node,
QDomDocument& doc,
QString& errorMessage,
const QgsReadWriteContext& context,
StyleCategories categories = AllStyleCategories) const virtual
Write just the symbology information for the layer into the document.
| Parameters | |
|---|---|
| node | the node that will have the style element added to it. |
| doc | the document that will have the QDomNode added. |
| errorMessage | reference to string that will be updated with any error messages |
| context | writing context (used for transform from absolute to relative paths) |
| categories | the style categories to be written |
| Returns | true in case of success. |
bool QgsMapLayer:: writeSymbology(QDomNode& node,
QDomDocument& doc,
QString& errorMessage,
const QgsReadWriteContext& context,
StyleCategories categories = AllStyleCategories) const pure virtual
Write the style for the layer into the docment provided.
| Parameters | |
|---|---|
| node | the node that will have the style element added to it. |
| doc | the document that will have the QDomNode added. |
| errorMessage | reference to string that will be updated with any error messages |
| context | writing context (used for transform from absolute to relative paths) |
| categories | the style categories to be written |
| Returns | true in case of success. |
void QgsMapLayer:: autoRefreshIntervalChanged(int interval) signal
Emitted when the auto refresh interval changes.
void QgsMapLayer:: configChanged() signal
Emitted whenever the configuration is changed.
The project listens to this signal to be marked as dirty.
void QgsMapLayer:: dataSourceChanged() signal
Emitted whenever the layer's data source has been changed.
void QgsMapLayer:: flagsChanged() signal
Emitted when layer's flags have been modified.
void QgsMapLayer:: legendChanged() signal
Signal emitted when legend of the layer has changed.
void QgsMapLayer:: metadataChanged() signal
Emitted when the layer's metadata is changed.
void QgsMapLayer:: nameChanged() signal
Emitted when the name has been changed.
void QgsMapLayer:: renderer3DChanged() signal
Signal emitted when 3D renderer associated with the layer has changed.
void QgsMapLayer:: rendererChanged() signal
Signal emitted when renderer is changed.
void QgsMapLayer:: repaintRequested(bool deferredUpdate = false) signal
By emitting this signal the layer tells that either appearance or content have been changed and any view showing the rendered layer should refresh itself.
If deferredUpdate is true then the layer will only be repainted when the canvas is next re-rendered, and will not trigger any canvas redraws itself.
void QgsMapLayer:: styleChanged() signal
Signal emitted whenever a change affects the layer's style.
Ie this may be triggered by renderer changes, label style changes, or other style changes such as blend mode or layer opacity changes.
void QgsMapLayer:: willBeDeleted() signal
Emitted in the destructor when the layer is about to be deleted, but it is still in a perfectly valid state: the last chance for other pieces of code for some cleanup if they use the layer.
void QgsMapLayer:: emitStyleChanged() public slot
Triggers an emission of the styleChanged() signal.
bool QgsMapLayer:: setDependencies(const QSet<QgsMapLayerDependency>& layers) virtual public slot
Sets the list of dependencies.
| Parameters | |
|---|---|
| layers | set of QgsMapLayerDependency. Only user-defined dependencies will be added |
| Returns | false if a dependency cycle has been detected |
void QgsMapLayer:: setMaximumScale(double scale) public slot
Sets the maximum map scale (i.e.
most "zoomed in" scale) at which the layer will be visible. The scale value indicates the scale denominator, e.g. 1000.0 for a 1:1000 map. A scale of 0 indicates no maximum scale visibility.
void QgsMapLayer:: setMinimumScale(double scale) public slot
Sets the minimum map scale (i.e.
most "zoomed out" scale) at which the layer will be visible. The scale value indicates the scale denominator, e.g. 1000.0 for a 1:1000 map. A scale of 0 indicates no minimum scale visibility.
void QgsMapLayer:: setRefreshOnNofifyMessage(const QString& message) public slot
Set the notification message that triggers repaine If refresh on notification is enabled, the notification will triggerRepaint only if the notification message is equal to.
| Parameters | |
|---|---|
| message | |
void QgsMapLayer:: setRefreshOnNotifyEnabled(bool enabled) public slot
Set whether provider notification is connected to triggerRepaint.
void QgsMapLayer:: setScaleBasedVisibility(bool enabled) public slot
Sets whether scale based visibility is enabled for the layer.
| Parameters | |
|---|---|
| enabled | set to true to enable scale based visibility |
void QgsMapLayer:: triggerRepaint(bool deferredUpdate = false) public slot
Will advise the map canvas (and any other interested party) that this layer requires to be repainted.
Will emit a repaintRequested() signal. If deferredUpdate is true then the layer will only be repainted when the canvas is next re-rendered, and will not trigger any canvas redraws itself.
void QgsMapLayer:: clone(QgsMapLayer* layer) const protected
Copies attributes like name, short name, ...
| Parameters | |
|---|---|
| layer | The copy recipient |
into another layer.
QString QgsMapLayer:: decodedSource(const QString& source,
const QString& dataProvider,
const QgsReadWriteContext& context) const virtual protected
Called by readLayerXML(), used by derived classes to decode provider's specific data source from project files.
| Parameters | |
|---|---|
| source | data source to decode, typically read from layer's DOM element "datasource" |
| dataProvider | string identification of data provider (e.g. "ogr"), typically read from layer's DOM element |
| context | reading context (e.g. for conversion between relative and absolute paths) |
| Returns | decoded source, typically to be used as the layer's datasource |
Typically resolving absolute or relative paths, usernames and passwords or drivers prefixes ("HDF5:")
QString QgsMapLayer:: encodedSource(const QString& source,
const QgsReadWriteContext& context) const virtual protected
Called by writeLayerXML(), used by derived classes to encode provider's specific data source to project files.
| Parameters | |
|---|---|
| source | data source to encode, typically QgsMapLayer:: |
| context | writing context (e.g. for conversion between relative and absolute paths) |
| Returns | encoded source, typically to be written in the DOM element "datasource" |
Typically resolving absolute or relative paths, usernames and passwords or drivers prefixes ("HDF5:")
void QgsMapLayer:: readCommonStyle(const QDomElement& layerElement,
const QgsReadWriteContext& context,
StyleCategories categories = AllStyleCategories) protected
Read style data common to all layer types.
void QgsMapLayer:: readCustomProperties(const QDomNode& layerNode,
const QString& keyStartsWith = QString()) protected
Read custom properties from project file.
| Parameters | |
|---|---|
| layerNode | note to read from |
| keyStartsWith | reads only properties starting with the specified string (or all if the string is empty) |
void QgsMapLayer:: writeCommonStyle(QDomElement& layerElement,
QDomDocument& document,
const QgsReadWriteContext& context,
StyleCategories categories = AllStyleCategories) const protected
Write style data common to all layer types.