QgsLayoutItemMapItem class
An item which is drawn inside a QgsLayoutItemMap, e.g., a grid or map overview.
Contents
Base classes
- class QgsLayoutObject
- A base class for objects which belong to a layout.
Derived classes
- class QgsLayoutItemMapGrid
- An individual grid which is drawn above the map content in a QgsLayoutItemMap.
- class QgsLayoutItemMapOverview
- An individual overview which is drawn above the map content in a QgsLayoutItemMap, and shows the extent of another QgsLayoutItemMap.
Public types
- enum StackingPosition { StackBelowMap, StackBelowMapLayer, StackAboveMapLayer, StackBelowMapLabels, StackAboveMapLabels }
- Item stacking position, specifies where the in the map's stack the item should be rendered.
Constructors, destructors, conversion operators
- QgsLayoutItemMapItem(const QString& name, QgsLayoutItemMap* map)
- Constructor for QgsLayoutItemMapItem, attached to the specified map.
Public functions
- void draw(QPainter* painter) pure virtual
- Draws the item on to a destination painter.
- auto enabled() const -> bool
- Returns whether the item will be drawn.
- void finalizeRestoreFromXml() virtual
- Called after all pending items have been restored from XML.
- auto id() const -> QString
- Returns the unique id for the map item.
- auto map() const -> const QgsLayoutItemMap*
- Returns the layout item map for the item.
- auto name() const -> QString
- Returns the friendly display name for the item.
- auto readXml(const QDomElement& element, const QDomDocument& doc, const QgsReadWriteContext& context) -> bool virtual
- Sets the map item state from a DOM document, where element is the DOM node corresponding to a 'LayoutMapGrid' tag.
- void setEnabled(bool enabled)
- Controls whether the item will be drawn.
- void setMap(QgsLayoutItemMap* map)
- Sets the corresponding layout map for the item.
- void setName(const QString& name)
- Sets the friendly display name for the item.
- void setStackingLayer(QgsMapLayer* layer)
- Sets the item's stacking layer, which specifies where the in the map's stack the item should be rendered.
- void setStackingPosition(StackingPosition position)
- Sets the item's stacking position, which specifies where the in the map's stack the item should be rendered.
- auto stackingLayer() const -> QgsMapLayer*
- Returns the item's stacking layer, which specifies where the in the map's stack the item should be rendered.
- auto stackingPosition() const -> StackingPosition
- Returns the item's stacking position, which specifies where the in the map's stack the item should be rendered.
- auto usesAdvancedEffects() const -> bool virtual
- Returns true if the item is drawn using advanced effects, such as blend modes.
- auto writeXml(QDomElement& element, QDomDocument& document, const QgsReadWriteContext& context) const -> bool virtual
- Stores map item state in a DOM element, where element is the DOM element corresponding to a 'LayoutMap' tag.
Protected variables
- bool mEnabled
- True if item is to be displayed on map.
- QgsLayoutItemMap* mMap
- Associated map.
- QString mName
- Friendly display name.
- QString mUuid
- Unique id.
Enum documentation
enum QgsLayoutItemMapItem:: StackingPosition
Item stacking position, specifies where the in the map's stack the item should be rendered.
| Enumerators | |
|---|---|
| StackBelowMap |
Render below all map layers. |
| StackBelowMapLayer |
Render below a specific map layer (see stackingLayer()) |
| StackAboveMapLayer |
Render above a specific map layer (see stackingLayer()) |
| StackBelowMapLabels |
Render above all map layers, but below map labels. |
| StackAboveMapLabels |
Render above all map layers and labels. |
Function documentation
QgsLayoutItemMapItem:: QgsLayoutItemMapItem(const QString& name,
QgsLayoutItemMap* map)
Constructor for QgsLayoutItemMapItem, attached to the specified map.
The name argument gives a friendly display name for the item.
bool QgsLayoutItemMapItem:: enabled() const
Returns whether the item will be drawn.
void QgsLayoutItemMapItem:: finalizeRestoreFromXml() virtual
Called after all pending items have been restored from XML.
Map items can use this method to run steps which must take place after all items have been restored to the layout, such as connecting to signals emitted by other items, which may not have existed in the layout at the time readXml() was called. E.g. an overview can use this to connect to its linked map item after restoration from XML.
const QgsLayoutItemMap* QgsLayoutItemMapItem:: map() const
Returns the layout item map for the item.
QString QgsLayoutItemMapItem:: name() const
Returns the friendly display name for the item.
bool QgsLayoutItemMapItem:: readXml(const QDomElement& element,
const QDomDocument& doc,
const QgsReadWriteContext& context) virtual
Sets the map item state from a DOM document, where element is the DOM node corresponding to a 'LayoutMapGrid' tag.
void QgsLayoutItemMapItem:: setEnabled(bool enabled)
Controls whether the item will be drawn.
Set enabled to true to enable drawing of the item.
void QgsLayoutItemMapItem:: setMap(QgsLayoutItemMap* map)
Sets the corresponding layout map for the item.
void QgsLayoutItemMapItem:: setName(const QString& name)
Sets the friendly display name for the item.
void QgsLayoutItemMapItem:: setStackingLayer(QgsMapLayer* layer)
Sets the item's stacking layer, which specifies where the in the map's stack the item should be rendered.
This setting is only used when stackingPosition() is StackBelowMapLayer or StackAboveMapLayer.
void QgsLayoutItemMapItem:: setStackingPosition(StackingPosition position)
Sets the item's stacking position, which specifies where the in the map's stack the item should be rendered.
QgsMapLayer* QgsLayoutItemMapItem:: stackingLayer() const
Returns the item's stacking layer, which specifies where the in the map's stack the item should be rendered.
This setting is only used when stackingPosition() is StackBelowMapLayer or StackAboveMapLayer.
StackingPosition QgsLayoutItemMapItem:: stackingPosition() const
Returns the item's stacking position, which specifies where the in the map's stack the item should be rendered.
bool QgsLayoutItemMapItem:: writeXml(QDomElement& element,
QDomDocument& document,
const QgsReadWriteContext& context) const virtual
Stores map item state in a DOM element, where element is the DOM element corresponding to a 'LayoutMap' tag.