Class: QgsLayoutItemLegend¶
-
class
qgis.core.
QgsLayoutItemLegend
(layout: QgsLayout)¶ Bases:
QgsLayoutItem
Constructor for
QgsLayoutItemLegend
, with the specified parentlayout
.A layout item subclass for map legends.
New in version 3.0.
- Parameters
layout –
-
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
- Return type
bool
-
boxSpace
(self) → float¶ Returns the legend box space.
See also
- Return type
float
-
childEvent
()¶
-
columnCount
(self) → int¶ Returns the legend column count.
See also
- Return type
int
-
columnSpace
(self) → float¶ Returns the legend column spacing.
See also
- Return type
float
-
connectNotify
()¶
-
contextMenuEvent
()¶
-
create
(layout: QgsLayout) → QgsLayoutItemLegend¶ Returns a new legend item for the specified
layout
.The caller takes responsibility for deleting the returned object.
- Parameters
layout (QgsLayout) –
- Return type
-
customEvent
()¶
-
disconnectNotify
()¶
-
displayName
(self) → str¶ - Return type
str
-
dragEnterEvent
()¶
-
dragLeaveEvent
()¶
-
dragMoveEvent
()¶
-
draw
(self, context: QgsLayoutItemRenderContext)¶ - Parameters
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
- Return type
bool
-
dropEvent
()¶
-
equalColumnWidth
(self) → bool¶ Returns whether column widths should be equalized.
See also
- Return type
bool
-
finalizeRestoreFromXml
(self)¶
-
focusInEvent
()¶
-
focusOutEvent
()¶
-
fontColor
(self) → QColor¶ Returns the legend font color.
See also
- Return type
QColor
-
hoverEnterEvent
()¶
-
hoverLeaveEvent
()¶
-
hoverMoveEvent
()¶
-
icon
(self) → QIcon¶ - Return type
QIcon
-
inputMethodEvent
()¶
-
inputMethodQuery
()¶
-
isSignalConnected
()¶
-
itemChange
()¶
-
itemFlags
(self) → QgsLayoutItem.Flags¶ - Return type
-
keyPressEvent
()¶
-
keyReleaseEvent
()¶
-
legendFilterByMapEnabled
(self) → bool¶ Find out whether legend items are filtered to show just the ones visible in the associated map
See also
- Return type
bool
-
legendFilterOutAtlas
(self) → bool¶ Returns whether to filter out legend elements outside of the current atlas feature.
See also
- Return type
bool
-
legendSettings
(self) → QgsLegendSettings¶ Returns the legend’s renderer settings object.
- Return type
-
lineSpacing
(self) → float¶ Returns the spacing in-between lines in layout units.
See also
- Return type
float
-
linkedMap
(self) → QgsLayoutItemMap¶ Returns the associated map.
See also
- Return type
-
model
(self) → QgsLegendModel¶ Returns the legend model.
- Return type
-
mouseDoubleClickEvent
()¶
-
mouseMoveEvent
()¶
-
mousePressEvent
()¶
-
mouseReleaseEvent
()¶
-
paint
(self, painter: QPainter, itemStyle: QStyleOptionGraphicsItem, pWidget: QWidget)¶ - Parameters
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
- Return type
QColor
-
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
- Return type
float
-
readObjectPropertiesFromElement
()¶
-
readPropertiesFromElement
(self, element: QDomElement, document: QDomDocument, context: QgsReadWriteContext) → bool¶ - Parameters
element (QDomElement) –
document (QDomDocument) –
context (QgsReadWriteContext) –
- Return type
bool
-
receivers
()¶
-
refresh
(self)¶
-
refreshBackgroundColor
()¶
-
refreshBlendMode
()¶
-
refreshDataDefinedProperty
(self, property: QgsLayoutObject.DataDefinedProperty = QgsLayoutObject.AllProperties)¶ - Parameters
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
- Return type
bool
-
rstyle
(self, s: QgsLegendStyle.Style) → QgsLegendStyle¶ Returns reference to modifiable legend style.
- Parameters
s (QgsLegendStyle.Style) –
- Return type
-
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
- Parameters
autoUpdate (bool) –
-
setBoxSpace
(self, space: float)¶ Sets the legend box
space
.See also
- Parameters
space (float) –
-
setColumnCount
(self, count: int)¶ Sets the legend column
count
.See also
- Parameters
count (int) –
-
setColumnSpace
(self, spacing: float)¶ Sets the legend column
spacing
.See also
- Parameters
spacing (float) –
-
setDrawRasterStroke
(self, enabled: bool)¶ Sets whether a stroke will be drawn around raster symbol items.
- Parameters
enabled (bool) – 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
- Parameters
equalize (bool) –
-
setFixedSize
()¶
-
setFontColor
(self, color: Union[QColor, Qt.GlobalColor])¶ Sets the legend font
color
.See also
- Parameters
color (Union[QColor) –
-
setLegendFilterByMapEnabled
(self, enabled: bool)¶ Set whether legend items should be filtered to show just the ones visible in the associated map.
See also
- Parameters
enabled (bool) –
-
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
- Parameters
doFilter (bool) –
-
setLineSpacing
(self, spacing: float)¶ Sets the
spacing
in-between multiple lines.See also
- Parameters
spacing (float) –
-
setLinkedMap
(self, map: QgsLayoutItemMap)¶ Sets the
map
to associate with the legend.See also
- Parameters
map (QgsLayoutItemMap) –
-
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() is true.See also
See also
See also
- Parameters
color (Union[QColor) –
-
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
- Parameters
width (float) –
-
setResizeToContents
(self, enabled: bool)¶ Sets whether the legend should automatically resize to fit its contents.
- Parameters
enabled (bool) – 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
- Parameters
enabled (bool) –
-
setStyle
(self, component: QgsLegendStyle.Style, style: QgsLegendStyle)¶ Sets the style of
component
tostyle
for the legend.- Parameters
component (QgsLegendStyle.Style) –
style (QgsLegendStyle) –
-
setStyleFont
(self, component: QgsLegendStyle.Style, font: QFont)¶ Sets the style
font
for a legendcomponent
.See also
- Parameters
component (QgsLegendStyle.Style) –
font (QFont) –
-
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
.- Parameters
component (QgsLegendStyle.Style) –
margin (float) –
-
setSymbolHeight
(self, height: float)¶ Sets the legend symbol
height
.See also
- Parameters
height (float) –
-
setSymbolWidth
(self, width: float)¶ Sets the legend symbol
width
.See also
- Parameters
width (float) –
-
setTitleAlignment
(self, alignment: Qt.AlignmentFlag)¶ Sets the
alignment
of the legend title.See also
- Parameters
alignment (Qt.AlignmentFlag) –
-
setWmsLegendHeight
(self, height: float)¶ Sets the WMS legend
height
.See also
- Parameters
height (float) –
-
setWmsLegendWidth
(self, width: float)¶ Sets the WMS legend
width
.See also
- Parameters
width (float) –
-
setWrapString
(self, string: str)¶ Sets the legend text wrapping
string
.See also
- Parameters
string (str) –
-
splitLayer
(self) → bool¶ Returns whether the legend items from a single layer can be split over multiple columns.
See also
- Return type
bool
-
style
(self, s: QgsLegendStyle.Style) → QgsLegendStyle¶ Returns legend style.
- Parameters
s (QgsLegendStyle.Style) –
- Return type
-
styleFont
(self, component: QgsLegendStyle.Style) → QFont¶ Returns the font settings for a legend
component
.See also
- Parameters
component (QgsLegendStyle.Style) –
- Return type
QFont
-
symbolHeight
(self) → float¶ Returns the legend symbol height.
See also
- Return type
float
-
symbolWidth
(self) → float¶ Returns the legend symbol width.
See also
- Return type
float
-
timerEvent
()¶
-
title
(self) → str¶ Returns the legend title.
See also
- Return type
str
-
titleAlignment
(self) → Qt.AlignmentFlag¶ Returns the alignment of the legend title.
See also
- Return type
Qt.AlignmentFlag
-
topLeftToReferencePoint
()¶
-
type
(self) → int¶ - Return type
int
-
updateFilterByMap
(self, redraw: bool = True)¶ Updates the legend content when filtered by map.
- Parameters
redraw (bool = True) –
-
updateLegend
(self)¶ Updates the model and all legend entries.
-
updateMicroFocus
()¶
-
wheelEvent
()¶
-
wmsLegendHeight
(self) → float¶ Returns the WMS legend height.
See also
- Return type
float
-
wmsLegendWidth
(self) → float¶ Returns the WMS legend width.
See also
- Return type
float
-
wrapString
(self) → str¶ Returns the legend text wrapping string.
See also
- Return type
str
-
writeObjectPropertiesToElement
()¶
-
writePropertiesToElement
(self, element: QDomElement, document: QDomDocument, context: QgsReadWriteContext) → bool¶ - Parameters
element (QDomElement) –
document (QDomDocument) –
context (QgsReadWriteContext) –
- Return type
bool