Class: QgsLayoutItemMapItemStack¶
A collection of map items which are drawn above the map content in a
QgsLayoutItemMap
. The item stack controls which items are
drawn and the order they are drawn in.
See also
Note
This is an abstract class, with methods which must be implemented by a subclass.
The following methods must be implemented: readXml()
Class Hierarchy¶
Subclasses¶
A collection of grids which is drawn above the map content in a |
|
A collection of overviews which are drawn above the map content in a |
Abstract Methods
Sets the item stack's state from a DOM document, where element is a DOM node corresponding to a 'LayoutMap' tag. |
Methods
Adds a new map item to the stack and takes ownership of the item. |
|
Returns a list of |
|
Returns whether any items within the stack contain advanced effects, such as blending modes. |
|
Draws the items from the stack on a specified painter. |
|
Returns |
|
Returns a reference to the item at the specified index within the stack. |
|
Moves an item which matching itemId up the stack, causing it to be rendered above other items. |
|
Moves an item which matching itemId up the stack, causing it to be rendered above other items. |
|
Removes an item which matching itemId from the stack and deletes the corresponding |
|
Clears the item stack and deletes all |
|
Returns the number of items in the stack. |
Virtual Methods
In PyQGIS, only methods marked as virtual
can be safely overridden in a Python subclass of QgsLayoutItemMapItemStack. See the FAQ for more details.
Called after all pending items have been restored from XML. |
|
Stores the state of the item stack in a DOM node, where element is the DOM element corresponding to a 'LayoutMap' tag. |
- class qgis.core.QgsLayoutItemMapItemStack[source]¶
Bases:
object
- __init__(map: QgsLayoutItemMap | None)
Constructor for QgsLayoutItemMapItemStack, attached to the specified
map
.- Parameters:
map (Optional[QgsLayoutItemMap])
- __init__(a0: QgsLayoutItemMapItemStack)
- Parameters:
- addItem(self, item: QgsLayoutItemMapItem | None)[source]¶
Adds a new map item to the stack and takes ownership of the item. The item will be added to the end of the stack, and rendered above any existing map items already present in the stack.
Note
After adding an item to the stack
update()
should be called for theQgsLayoutItemMap
to prevent rendering artifacts.See also
- Parameters:
item (Optional[QgsLayoutItemMapItem])
- asList(self) List[QgsLayoutItemMapItem] ¶
Returns a list of
QgsLayoutItemMapItems
contained by the stack.- Return type:
List[QgsLayoutItemMapItem]
- containsAdvancedEffects(self) bool [source]¶
Returns whether any items within the stack contain advanced effects, such as blending modes.
- Return type:
bool
- drawItems(self, painter: QPainter | None, ignoreStacking: bool = True)[source]¶
Draws the items from the stack on a specified
painter
.If
ignoreStacking
isTrue
, then all items will be drawn, regardless of their actual stacking position settings. If it isFalse
, only items which are set to stack above the map item will be drawn.- Parameters:
painter (Optional[QPainter])
ignoreStacking (bool = True)
- virtual finalizeRestoreFromXml(self)[source]¶
Called after all pending items have been restored from XML. Map item stacks 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.See also
- hasEnabledItems(self) bool [source]¶
Returns
True
if the stack has any currently enabled items.Added in version 3.10.
- Return type:
bool
- item(self, index: int) QgsLayoutItemMapItem | None [source]¶
Returns a reference to the item at the specified
index
within the stack.- Parameters:
index (int)
- Return type:
Optional[QgsLayoutItemMapItem]
- item(self, itemId: str | None) QgsLayoutItemMapItem | None [source]
Returns a reference to an item which matching
itemId
within the stack.- Parameters:
itemId (Optional[str])
- Return type:
Optional[QgsLayoutItemMapItem]
- moveItemDown(self, itemId: str | None)[source]¶
Moves an item which matching
itemId
up the stack, causing it to be rendered above other items.Note
After moving an item within the stack,
update()
should be called for theQgsLayoutItemMap
to redraw the map with the new item stack order.See also
- Parameters:
itemId (Optional[str])
- moveItemUp(self, itemId: str | None)[source]¶
Moves an item which matching
itemId
up the stack, causing it to be rendered above other items.Note
After moving an item within the stack,
update()
should be called for theQgsLayoutItemMap
to redraw the map with the new item stack order.See also
- Parameters:
itemId (Optional[str])
- abstract readXml(self, element: QDomElement, doc: QDomDocument, context: QgsReadWriteContext) bool [source]¶
Sets the item stack’s state from a DOM document, where
element
is a DOM node corresponding to a ‘LayoutMap’ tag. ReturnsTrue
if read was successful.See also
- Parameters:
element (QDomElement)
doc (QDomDocument)
context (QgsReadWriteContext)
- Return type:
bool
- removeItem(self, itemId: str | None)[source]¶
Removes an item which matching
itemId
from the stack and deletes the correspondingQgsLayoutItemMapItem
Note
After removing an item from the stack,
update()
should be called for theQgsLayoutItemMap
to prevent rendering artifacts.See also
- Parameters:
itemId (Optional[str])
- removeItems(self)[source]¶
Clears the item stack and deletes all
QgsLayoutItemMapItems
contained by the stack
- virtual writeXml(self, element: QDomElement, doc: QDomDocument, context: QgsReadWriteContext) bool [source]¶
Stores the state of the item stack in a DOM node, where
element
is the DOM element corresponding to a ‘LayoutMap’ tag. ReturnsTrue
if write was successful.See also
- Parameters:
element (QDomElement)
doc (QDomDocument)
context (QgsReadWriteContext)
- Return type:
bool