Class: QgsLayoutItemLegend¶
-
class
qgis.core.
QgsLayoutItemLegend
(layout: QgsLayout)¶ Bases:
qgis._core.QgsLayoutItem
Constructor for QgsLayoutItemLegend, with the specified parent
layout
.A layout item subclass for map legends.
New in version 3.0: Enums
Methods
Sets the legend’s item bounds to fit the whole legend content.
Returns whether the legend content should auto update to reflect changes in the project’s layer tree.
Returns the legend box space.
Returns the legend column count.
Returns the legend column spacing.
Returns a new legend item for the specified
layout
.Returns whether a stroke will be drawn around raster symbol items.
Returns whether column widths should be equalized.
Returns the legend font color.
Find out whether legend items are filtered to show just the ones visible in the associated map
Returns whether to filter out legend elements outside of the current atlas feature.
Returns the legend’s renderer settings object.
Returns the spacing in-between lines in layout units.
Returns the associated map.
Returns the legend model.
Returns the stroke color for the stroke drawn around raster symbol items.
Returns the stroke width (in layout units) for the stroke drawn around raster symbol items.
Returns whether the legend should automatically resize to fit its contents.
Returns reference to modifiable legend style.
Sets whether the legend content should auto update to reflect changes in the project’s layer tree.
Sets the legend box
space
.Sets the legend column
count
.Sets the legend column
spacing
.Sets whether a stroke will be drawn around raster symbol items.
Sets whether column widths should be equalized.
Sets the legend font
color
.Set whether legend items should be filtered to show just the ones visible in the associated map.
When set to
True
, during an atlas rendering, it will filter out legend elements where features are outside the current atlas feature.Sets the
spacing
in-between multiple lines.Sets the
map
to associate with the legend.Sets the stroke
color
for the stroke drawn around raster symbol items.Sets the stroke width for the stroke drawn around raster symbol items.
Sets whether the legend should automatically resize to fit its contents.
Sets whether the legend items from a single layer can be split over multiple columns.
Sets the style of
component
tostyle
for the legend.Sets the style
font
for a legendcomponent
.Set the
margin
for a legendcomponent
.Sets the
alignment
for placement of legend symbols.Sets the legend symbol
height
.Sets the legend symbol
width
.Sets the legend
title
.Sets the
alignment
of the legend title.Sets the WMS legend
height
.Sets the WMS legend
width
.Sets the legend text wrapping
string
.Returns whether the legend items from a single layer can be split over multiple columns.
Returns legend style.
Returns the font settings for a legend
component
.Returns the alignment for placement of legend symbols.
Returns the legend symbol height.
Returns the legend symbol width.
Returns the legend title.
Returns the alignment of the legend title.
Updates the legend content when filtered by map.
Updates the model and all legend entries.
Returns the WMS legend height.
Returns the WMS legend width.
Returns the legend text wrapping string.
Signals
Attributes
-
adjustBoxSize
(self)¶ Sets the legend’s item bounds to fit the whole legend content.
-
adjustPointForReferencePosition
()¶
-
applyDataDefinedSize
()¶
-
applyItemSizeConstraint
()¶
-
autoUpdateModel
(self) → bool¶ Returns whether the legend content should auto update to reflect changes in the project’s layer tree.
See also
-
boxSpace
(self) → float¶ Returns the legend box space.
See also
-
childEvent
()¶
-
columnCount
(self) → int¶ Returns the legend column count.
See also
-
columnSpace
(self) → float¶ Returns the legend column spacing.
See also
-
connectNotify
()¶
-
contextMenuEvent
()¶
-
create
(layout: QgsLayout) → QgsLayoutItemLegend¶ Returns a new legend item for the specified
layout
.The caller takes responsibility for deleting the returned object.
-
createExpressionContext
(self) → QgsExpressionContext¶
-
customEvent
()¶
-
disconnectNotify
()¶
-
displayName
(self) → str¶
-
dragEnterEvent
()¶
-
dragLeaveEvent
()¶
-
dragMoveEvent
()¶
-
draw
(self, context: QgsLayoutItemRenderContext)¶
-
drawBackground
()¶
-
drawDebugRect
()¶
-
drawFrame
()¶
-
drawRasterStroke
(self) → bool¶ Returns whether a stroke will be drawn around raster symbol items.
See also
See also
See also
-
dropEvent
()¶
-
equalColumnWidth
(self) → bool¶ Returns whether column widths should be equalized.
See also
-
finalizeRestoreFromXml
(self)¶
-
focusInEvent
()¶
-
focusOutEvent
()¶
-
fontColor
(self) → QColor¶ Returns the legend font color.
See also
-
hoverEnterEvent
()¶
-
hoverLeaveEvent
()¶
-
hoverMoveEvent
()¶
-
icon
(self) → QIcon¶
-
inputMethodEvent
()¶
-
inputMethodQuery
()¶
-
isSignalConnected
()¶
-
itemChange
()¶
-
itemFlags
(self) → QgsLayoutItem.Flags¶
-
keyPressEvent
()¶
-
keyReleaseEvent
()¶
-
legendFilterByMapEnabled
(self) → bool¶ Find out whether legend items are filtered to show just the ones visible in the associated map
See also
-
legendFilterOutAtlas
(self) → bool¶ Returns whether to filter out legend elements outside of the current atlas feature.
See also
-
legendSettings
(self) → QgsLegendSettings¶ Returns the legend’s renderer settings object.
-
lineSpacing
(self) → float¶ Returns the spacing in-between lines in layout units.
See also
-
linkedMap
(self) → QgsLayoutItemMap¶ Returns the associated map.
See also
-
model
(self) → QgsLegendModel¶ Returns the legend model.
-
mouseDoubleClickEvent
()¶
-
mouseMoveEvent
()¶
-
mousePressEvent
()¶
-
mouseReleaseEvent
()¶
-
paint
(self, painter: QPainter, itemStyle: QStyleOptionGraphicsItem, pWidget: QWidget)¶
-
positionAtReferencePoint
()¶
-
prepareGeometryChange
()¶
-
rasterStrokeColor
(self) → QColor¶ Returns the stroke color for the stroke drawn around raster symbol items. The stroke is only drawn if drawRasterStroke() is
True
.See also
See also
See also
-
rasterStrokeWidth
(self) → float¶ Returns the stroke width (in layout units) for the stroke drawn around raster symbol items. The stroke is only drawn if drawRasterStroke() is
True
.See also
See also
See also
-
readObjectPropertiesFromElement
()¶
-
readPropertiesFromElement
(self, element: QDomElement, document: QDomDocument, context: QgsReadWriteContext) → bool¶
-
receivers
()¶
-
refresh
(self)¶
-
refreshBackgroundColor
()¶
-
refreshBlendMode
()¶
-
refreshDataDefinedProperty
(self, property: QgsLayoutObject.DataDefinedProperty = QgsLayoutObject.AllProperties)¶
-
refreshFrame
()¶
-
refreshItemPosition
()¶
-
refreshItemRotation
()¶
-
refreshItemSize
()¶
-
refreshOpacity
()¶
-
resizeToContents
(self) → bool¶ Returns whether the legend should automatically resize to fit its contents.
See also
-
rstyle
(self, s: QgsLegendStyle.Style) → QgsLegendStyle¶ Returns reference to modifiable legend style.
-
sceneEvent
()¶
-
sceneEventFilter
()¶
-
sender
()¶
-
senderSignalIndex
()¶
-
setAutoUpdateModel
(self, autoUpdate: bool)¶ Sets whether the legend content should auto update to reflect changes in the project’s layer tree.
See also
-
setBoxSpace
(self, space: float)¶ Sets the legend box
space
.See also
-
setColumnCount
(self, count: int)¶ Sets the legend column
count
.See also
-
setColumnSpace
(self, spacing: float)¶ Sets the legend column
spacing
.See also
-
setDrawRasterStroke
(self, enabled: bool)¶ Sets whether a stroke will be drawn around raster symbol items.
- Parameters
enabled – set to
True
to draw borders
See also
See also
See also
-
setEqualColumnWidth
(self, equalize: bool)¶ Sets whether column widths should be equalized.
See also
-
setFixedSize
()¶
-
setFontColor
(self, color: Union[QColor, Qt.GlobalColor])¶ Sets the legend font
color
.See also
-
setLegendFilterByMapEnabled
(self, enabled: bool)¶ Set whether legend items should be filtered to show just the ones visible in the associated map.
See also
-
setLegendFilterOutAtlas
(self, doFilter: bool)¶ When set to
True
, during an atlas rendering, it will filter out legend elements where features are outside the current atlas feature.See also
-
setLineSpacing
(self, spacing: float)¶ Sets the
spacing
in-between multiple lines.See also
-
setLinkedMap
(self, map: QgsLayoutItemMap)¶ Sets the
map
to associate with the legend.See also
-
setMinimumSize
()¶
-
setRasterStrokeColor
(self, color: Union[QColor, Qt.GlobalColor])¶ Sets the stroke
color
for the stroke drawn around raster symbol items. The stroke is only drawn if drawRasterStroke() isTrue
.See also
See also
See also
-
setRasterStrokeWidth
(self, width: float)¶ Sets the stroke width for the stroke drawn around raster symbol items. The stroke is only drawn if drawRasterStroke() is
True
.See also
See also
See also
-
setResizeToContents
(self, enabled: bool)¶ Sets whether the legend should automatically resize to fit its contents.
- Parameters
enabled – set to
False
to disable automatic resizing. The legend frame will not be expanded to fit legend items, and items may be cropped from display.
See also
-
setSplitLayer
(self, enabled: bool)¶ Sets whether the legend items from a single layer can be split over multiple columns.
See also
-
setStyle
(self, component: QgsLegendStyle.Style, style: QgsLegendStyle)¶ Sets the style of
component
tostyle
for the legend.
-
setStyleFont
(self, component: QgsLegendStyle.Style, font: QFont)¶ Sets the style
font
for a legendcomponent
.See also
-
setStyleMargin
(self, component: QgsLegendStyle.Style, margin: float)¶ Set the
margin
for a legendcomponent
.setStyleMargin(self, component: QgsLegendStyle.Style, side: QgsLegendStyle.Side, margin: float) Set the
margin
for a particularside
of a legendcomponent
.
-
setSymbolAlignment
(self, alignment: Qt.AlignmentFlag)¶ Sets the
alignment
for placement of legend symbols.Only Qt.AlignLeft or Qt.AlignRight are supported values.
See also
New in version 3.10.
-
setSymbolHeight
(self, height: float)¶ Sets the legend symbol
height
.See also
-
setSymbolWidth
(self, width: float)¶ Sets the legend symbol
width
.See also
-
setTitleAlignment
(self, alignment: Qt.AlignmentFlag)¶ Sets the
alignment
of the legend title.See also
-
setWmsLegendHeight
(self, height: float)¶ Sets the WMS legend
height
.See also
-
setWmsLegendWidth
(self, width: float)¶ Sets the WMS legend
width
.See also
-
setWrapString
(self, string: str)¶ Sets the legend text wrapping
string
.See also
-
splitLayer
(self) → bool¶ Returns whether the legend items from a single layer can be split over multiple columns.
See also
-
style
(self, s: QgsLegendStyle.Style) → QgsLegendStyle¶ Returns legend style.
-
styleFont
(self, component: QgsLegendStyle.Style) → QFont¶ Returns the font settings for a legend
component
.See also
-
symbolAlignment
(self) → Qt.AlignmentFlag¶ Returns the alignment for placement of legend symbols.
Only Qt.AlignLeft or Qt.AlignRight are supported values.
See also
New in version 3.10.
-
symbolHeight
(self) → float¶ Returns the legend symbol height.
See also
-
symbolWidth
(self) → float¶ Returns the legend symbol width.
See also
-
timerEvent
()¶
-
title
(self) → str¶ Returns the legend title.
See also
-
titleAlignment
(self) → Qt.AlignmentFlag¶ Returns the alignment of the legend title.
See also
-
topLeftToReferencePoint
()¶
-
type
(self) → int¶
-
updateFilterByMap
(self, redraw: bool = True)¶ Updates the legend content when filtered by map.
-
updateLegend
(self)¶ Updates the model and all legend entries.
-
updateMicroFocus
()¶
-
wheelEvent
()¶
-
wmsLegendHeight
(self) → float¶ Returns the WMS legend height.
See also
-
wmsLegendWidth
(self) → float¶ Returns the WMS legend width.
See also
-
wrapString
(self) → str¶ Returns the legend text wrapping string.
See also
-
writeObjectPropertiesToElement
()¶
-
writePropertiesToElement
(self, element: QDomElement, document: QDomDocument, context: QgsReadWriteContext) → bool¶
-