Subgroup: Layout

Class: QgsLayoutNodesItem

class qgis.core.QgsLayoutNodesItem

Bases: qgis._core.QgsLayoutItem

An abstract layout item that provides generic methods for node based shapes such as polygon or polylines.

New in version 3.0: Methods

acceptDrops
acceptHoverEvents
acceptTouchEvents
acceptedMouseButtons
addNode Add a node in current shape.
adjustPointForReferencePosition
advance
applyDataDefinedSize
applyItemSizeConstraint
attemptMove Attempts to move the item to a specified point.
attemptMoveBy Attempts to shift the item’s position by a specified deltaX and deltaY, in layout units.
attemptResize Attempts to resize the item to a specified target size.
attemptSetSceneRect Attempts to update the item’s position and size to match the passed rect in layout coordinates.
backgroundColor Returns the background color for this item.
beginCommand Starts new undo command for this item.
blendMode Returns the item’s composition blending mode.
blockSignals
boundingRect
boundingRegion
boundingRegionGranularity
brush
cacheMode
cancelCommand Cancels the current item command and discards it.
childEvent
childItems
children
childrenBoundingRect
cleanup Called just before a batch of items are deleted, allowing them to run cleanup tasks.
clearFocus
clipPath
collidesWithItem
collidesWithPath
collidingItems
commonAncestorItem
computeDistance Compute an euclidian distance between 2 nodes.
connectNotify
contains
containsAdvancedEffects Returns true if the item contains contents with blend modes or transparency effects which can only be reproduced by rastering the item.
contextMenuEvent
createCommand
createExpressionContext
cursor
customEvent
customProperties Return list of keys stored in custom properties for the object.
customProperty Read a custom property from the object.
data
dataDefinedProperties Returns a reference to the object’s property collection, used for data defined overrides.
deleteLater
deselectNode Deselects any selected nodes.
deviceTransform
disconnect
disconnectNotify
displayName Get item display name.
dragEnterEvent
dragLeaveEvent
dragMoveEvent
draw
drawBackground
drawDebugRect
drawFrame
dropEvent
dumpObjectInfo
dumpObjectTree
dynamicPropertyNames
effectiveOpacity
endCommand Completes the current item command and push it onto the layout’s undo stack.
ensureVisible ensureVisible(self, float, float, float, float, xMargin: int = 50, yMargin: int = 50)
estimatedFrameBleed
event
eventFilter
excludeFromExports Returns whether the item should be excluded from layout exports and prints.
filtersChildEvents
finalizeRestoreFromXml Called after all pending items have been restored from XML.
findChild findChild(self, Tuple, name: str = ‘’, options: Union[Qt.FindChildOptions, Qt.FindChildOption] = Qt.FindChildrenRecursively) -> QObject
findChildren findChildren(self, Tuple, name: str = ‘’, options: Union[Qt.FindChildOptions, Qt.FindChildOption] = Qt.FindChildrenRecursively) -> List[QObject]
fixedSize Returns the fixed size of the item, if applicable, or an empty size if item can be freely resized.
flags
focusInEvent
focusItem
focusOutEvent
focusProxy
frameEnabled Returns true if the item includes a frame.
frameJoinStyle Returns the join style used for drawing the item’s frame.
frameStrokeColor Returns the frame’s stroke color.
frameStrokeWidth Returns the frame’s stroke width.
grabKeyboard
grabMouse
graphicsEffect
group
hasBackground Returns true if the item has a background.
hasCursor
hasFocus
hide
hoverEnterEvent
hoverLeaveEvent
hoverMoveEvent
icon Returns the item’s icon.
id Returns the item’s ID name.
inherits
inputMethodEvent
inputMethodHints
inputMethodQuery
installEventFilter
installSceneEventFilter
invalidateCache Forces a deferred update of any cached image the item uses.
isActive
isAncestorOf
isBlockedByModalPanel
isClipped
isEnabled
isGroupMember Returns true if the item is part of a QgsLayoutItemGroup group.
isLocked Returns true if the item is locked, and cannot be interacted with using the mouse.
isObscured isObscured(self, float, float, float, float) -> bool
isObscuredBy
isPanel
isSelected
isSignalConnected
isUnderMouse
isVisible
isVisibleTo
isWidget
isWidgetType
isWindow
isWindowType
itemChange
itemOpacity Returns the item’s opacity.
itemRotation Returns the current rotation for the item, in degrees clockwise.
itemTransform
keyPressEvent
keyReleaseEvent
killTimer
layout Returns the layout the object is attached to.
mapFromItem mapFromItem(self, QGraphicsItem, QRectF) -> QPolygonF
mapFromParent mapFromParent(self, QRectF) -> QPolygonF
mapFromScene mapFromScene(self, QRectF) -> QPolygonF
mapRectFromItem mapRectFromItem(self, QGraphicsItem, float, float, float, float) -> QRectF
mapRectFromParent mapRectFromParent(self, float, float, float, float) -> QRectF
mapRectFromScene mapRectFromScene(self, float, float, float, float) -> QRectF
mapRectToItem mapRectToItem(self, QGraphicsItem, float, float, float, float) -> QRectF
mapRectToParent mapRectToParent(self, float, float, float, float) -> QRectF
mapRectToScene mapRectToScene(self, float, float, float, float) -> QRectF
mapToItem mapToItem(self, QGraphicsItem, QRectF) -> QPolygonF
mapToParent mapToParent(self, QRectF) -> QPolygonF
mapToScene mapToScene(self, QRectF) -> QPolygonF
metaObject
minimumSize Returns the minimum allowed size of the item, if applicable, or an empty size if item can be freely resized.
mouseDoubleClickEvent
mouseMoveEvent
mousePressEvent
mouseReleaseEvent
moveBy
moveContent Moves the content of the item, by a specified dx and dy in layout units.
moveNode Moves a node to a new position.
moveToThread
nodeAtPosition Search for the nearest node in the shape within a maximal area.
nodePosition Gets the position of a node in scene coordinates.
nodes Returns the nodes the shape consists of.
nodesSize Returns the number of nodes in the shape.
numberExportLayers Returns the number of layers that this item requires for exporting during layered exports (e.g.
objectName
opacity
opaqueArea
page Returns the page the item is currently on, with the first page returning 0.
pagePos Returns the item’s position (in layout units) relative to the top left corner of its current page.
pagePositionWithUnits Returns the item’s position (in item units) relative to the top left corner of its current page.
paint Handles preparing a paint surface for the layout item and painting the item’s content.
panel
panelModality
parent
parentGroup Returns the item’s parent group, if the item is part of a QgsLayoutItemGroup group.
parentItem
parentObject
parentWidget
pen
pos
positionAtReferencePoint
positionWithUnits Returns the item’s current position, including units.
prepareGeometryChange
property
propertyDefinitions Returns the layout object property definitions.
pyqtConfigure Each keyword argument is either the name of a Qt property or a Qt signal.
readObjectPropertiesFromElement
readPropertiesFromElement
readXml Sets the item state from a DOM element.
receivers
rect
rectWithFrame Returns the item’s rectangular bounds, including any bleed caused by the item’s frame.
redraw Triggers a redraw (update) of the item.
referencePoint Returns the reference point for positioning of the layout item.
refresh Refreshes the item, causing a recalculation of any property overrides and recalculation of its position and size.
refreshBackgroundColor
refreshBlendMode
refreshDataDefinedProperty Refreshes a data defined property for the item by reevaluating the property’s value and redrawing the item with this new value.
refreshFrame
refreshItemPosition
refreshItemRotation
refreshItemSize
refreshOpacity
removeCustomProperty Remove a custom property from the object.
removeEventFilter
removeNode Remove a node with specified index from the shape.
removeSceneEventFilter
requiresRasterization Returns true if the item is drawn in such a way that forces the whole layout to be rasterized when exporting to vector formats.
rescaleToFitBoundingBox Rescale the current shape according to the item’s bounding box.
resetTransform
rotateItem Rotates the item by a specified angle in degrees clockwise around a specified reference point.
rotation
scale
scene
sceneBoundingRect
sceneEvent
sceneEventFilter
scenePos
sceneTransform
scroll
selectedNode Returns the currently selected node, or -1 if no node is selected.
sender
senderSignalIndex
setAcceptDrops
setAcceptHoverEvents
setAcceptTouchEvents
setAcceptedMouseButtons
setActive
setBackgroundColor Sets the background color for this item.
setBackgroundEnabled Sets whether this item has a background drawn under it or not.
setBlendMode Sets the item’s composition blending mode.
setBoundingRegionGranularity
setBrush
setCacheMode
setCursor
setCustomProperty Set a custom property for the object.
setData
setDataDefinedProperties Sets the objects’s property collection, used for data defined overrides.
setDisplayNodes Set whether the item’s nodes should be displayed.
setEnabled
setExcludeFromExports Sets whether the item should be excluded from layout exports and prints.
setFiltersChildEvents
setFixedSize
setFlag
setFlags
setFocus
setFocusProxy
setFrameEnabled Sets whether this item has a frame drawn around it or not.
setFrameJoinStyle Sets the join style used when drawing the item’s frame.
setFrameStrokeColor Sets the frame stroke color.
setFrameStrokeWidth Sets the frame stroke width.
setGraphicsEffect
setGroup
setId Set the item’s id name.
setInputMethodHints
setItemOpacity Sets the item’s opacity.
setItemRotation Sets the layout item’s rotation, in degrees clockwise.
setLocked Sets whether the item is locked, preventing mouse interactions with the item.
setMinimumSize
setMoveContentPreviewOffset Sets temporary offset for the item, by a specified dx and dy in layout units.
setNodes Sets the nodes the shape consists of.
setObjectName
setOpacity
setPanelModality
setParent
setParentGroup Sets the item’s parent group.
setParentItem
setPen
setPos setPos(self, float, float)
setProperty
setRect setRect(self, float, float, float, float)
setReferencePoint Sets the reference point for positioning of the layout item.
setRotation
setScale
setSelected Sets whether the item should be selected.
setSelectedNode Selects a node by index.
setToolTip
setTransform
setTransformOriginPoint setTransformOriginPoint(self, float, float)
setTransformations
setVisibility Sets whether the item is visible.
setVisible
setX
setY
setZValue
shape
shouldDrawItem Returns whether the item should be drawn in the current context.
show
signalsBlocked
sizeWithUnits Returns the item’s current size, including units.
stackBefore
startTimer
templateUuid Returns the item’s original identification string.
thread
timerEvent
toGraphicsObject
toolTip
topLeftToReferencePoint
topLevelItem
topLevelWidget
tr
transform
transformOriginPoint
transformations
type Returns a unique graphics item type identifier.
ungrabKeyboard
ungrabMouse
unsetCursor
update update(self, float, float, float, float)
updateBoundingRect Called when the bounding rect of the item should recalculated.
updateMicroFocus
updateSceneRect Update the current scene rectangle for this item.
uuid Returns the item identification string.
wheelEvent
window
writeObjectPropertiesToElement
writePropertiesToElement
writeXml Stores the item state in a DOM element.
x
y
zValue
zoomContent Zooms content of item.

Attributes

AllProperties
BackgroundColor
BlendMode
DeviceCoordinateCache
EvaluatedValue
ExcludeFromExports
FrameColor
ItemAcceptsInputMethod
ItemChildAddedChange
ItemChildRemovedChange
ItemClipsChildrenToShape
ItemClipsToShape
ItemContainsChildrenInShape
ItemCoordinateCache
ItemCursorChange
ItemCursorHasChanged
ItemDoesntPropagateOpacityToChildren
ItemEnabledChange
ItemEnabledHasChanged
ItemFlagsChange
ItemFlagsHaveChanged
ItemHasNoContents
ItemHeight
ItemIgnoresParentOpacity
ItemIgnoresTransformations
ItemIsFocusable
ItemIsMovable
ItemIsPanel
ItemIsSelectable
ItemMatrixChange
ItemNegativeZStacksBehindParent
ItemOpacityChange
ItemOpacityHasChanged
ItemParentChange
ItemParentHasChanged
ItemPositionChange
ItemPositionHasChanged
ItemRotation
ItemRotationChange
ItemRotationHasChanged
ItemScaleChange
ItemScaleHasChanged
ItemSceneChange
ItemSceneHasChanged
ItemScenePositionHasChanged
ItemSelectedChange
ItemSelectedHasChanged
ItemSendsGeometryChanges
ItemSendsScenePositionChanges
ItemStacksBehindParent
ItemToolTipChange
ItemToolTipHasChanged
ItemTransformChange
ItemTransformHasChanged
ItemTransformOriginPointChange
ItemTransformOriginPointHasChanged
ItemUsesExtendedStyleOption
ItemVisibleChange
ItemVisibleHasChanged
ItemWidth
ItemZValueChange
ItemZValueHasChanged
LegendColumnCount
LegendTitle
LowerLeft
LowerMiddle
LowerRight
MapAtlasMargin
MapLayers
MapRotation
MapScale
MapStylePreset
MapXMax
MapXMin
MapYMax
MapYMin
Middle
MiddleLeft
MiddleRight
NoCache
NoProperty
NonModal
NumPages
Opacity
OriginalValue
PageNumber
PanelModal
PaperHeight
PaperOrientation
PaperWidth
PictureSource
PictureSvgBackgroundColor
PictureSvgStrokeColor
PictureSvgStrokeWidth
PositionX
PositionY
PresetPaperSize
ScalebarFillColor
ScalebarFillColor2
ScalebarLineColor
ScalebarLineWidth
SceneModal
SourceUrl
TestProperty
Transparency
Type
UndoArrowHeadFillColor
UndoArrowHeadStrokeColor
UndoArrowHeadWidth
UndoArrowStrokeWidth
UndoAtlasMargin
UndoBackgroundColor
UndoCustomCommand
UndoGridFramePenColor
UndoIncrementalMove
UndoIncrementalResize
UndoLabelFont
UndoLabelFontColor
UndoLabelMargin
UndoLabelText
UndoLegendBoxSpace
UndoLegendColumnCount
UndoLegendColumnSpace
UndoLegendFontColor
UndoLegendGroupFont
UndoLegendGroupSpace
UndoLegendIconSymbolSpace
UndoLegendItemFont
UndoLegendLayerFont
UndoLegendLayerSpace
UndoLegendLineSpacing
UndoLegendRasterStrokeColor
UndoLegendRasterStrokeWidth
UndoLegendSymbolHeight
UndoLegendSymbolSpace
UndoLegendSymbolWidth
UndoLegendText
UndoLegendTitleFont
UndoLegendTitleSpaceBottom
UndoLegendWmsLegendHeight
UndoLegendWmsLegendWidth
UndoMapAnnotationDistance
UndoMapGridAnnotationFontColor
UndoMapGridFrameFill1Color
UndoMapGridFrameFill2Color
UndoMapGridLineSymbol
UndoMapGridMarkerSymbol
UndoMapRotation
UndoNodeMove
UndoNone
UndoOpacity
UndoOverviewStyle
UndoPictureFillColor
UndoPictureNorthOffset
UndoPictureRotation
UndoPictureStrokeColor
UndoPictureStrokeWidth
UndoRotation
UndoScaleBarBoxContentSpace
UndoScaleBarFillColor
UndoScaleBarFillColor2
UndoScaleBarFontColor
UndoScaleBarHeight
UndoScaleBarLabelBarSize
UndoScaleBarLineWidth
UndoScaleBarMapUnitsSegment
UndoScaleBarSegmentSize
UndoScaleBarSegments
UndoScaleBarSegmentsLeft
UndoScaleBarStrokeColor
UndoScaleBarUnitText
UndoSetId
UndoShapeCornerRadius
UndoShapeStyle
UndoStrokeColor
UndoStrokeWidth
UndoZoomContent
UpperLeft
UpperMiddle
UpperRight
UserType
changed Emitted when the object’s properties change.
destroyed destroyed(self, QObject = None) [signal]
frameChanged Emitted if the item’s frame style changes.
lockChanged Emitted if the item’s lock status changes.
objectNameChanged objectNameChanged(self, str) [signal]
rotationChanged Emitted on item rotation change.
sizePositionChanged Emitted when the item’s size or position changes.
staticMetaObject
addNode(self, point: Union[QPointF, QPoint], checkArea: bool = True, radius: float = 10) → bool

Add a node in current shape.

Parameters:
  • point – is the location of the new node (in scene coordinates)
  • checkArea – is a flag to indicate if there’s a space constraint.
  • radius – is the space contraint and is used only if checkArea is

true. Typically, if this flag is true, the new node has to be nearer than radius to the shape to be added.

adjustPointForReferencePosition()
applyDataDefinedSize()
applyItemSizeConstraint()
boundingRect(self) → QRectF
childEvent()
computeDistance(self, pt1: Union[QPointF, QPoint], pt2: Union[QPointF, QPoint]) → float

Compute an euclidian distance between 2 nodes.

connectNotify()
contextMenuEvent()
customEvent()
deselectNode(self)

Deselects any selected nodes.

disconnectNotify()
dragEnterEvent()
dragLeaveEvent()
dragMoveEvent()
draw(self, context: QgsRenderContext, itemStyle: QStyleOptionGraphicsItem = None)
drawBackground()
drawDebugRect()
drawFrame()
dropEvent()
estimatedFrameBleed(self) → float
focusInEvent()
focusOutEvent()
hoverEnterEvent()
hoverLeaveEvent()
hoverMoveEvent()
inputMethodEvent()
inputMethodQuery()
isSignalConnected()
itemChange()
keyPressEvent()
keyReleaseEvent()
mouseDoubleClickEvent()
mouseMoveEvent()
mousePressEvent()
mouseReleaseEvent()
moveNode(self, index: int, node: Union[QPointF, QPoint]) → bool

Moves a node to a new position.

Parameters:
  • index – the index of the node to move
  • node – is the new position in scene coordinate
nodeAtPosition(self, point: Union[QPointF, QPoint], searchInRadius: bool = True, radius: float = 10) → int

Search for the nearest node in the shape within a maximal area. Returns the index of the nearest node or -1 if no node was found.

Parameters:
  • point – is the location to search for nodes from (in scene coordinates)
  • searchInRadius – is a flag to indicate if the area of research is

limited in space. :param radius: is only used if searchInRadius is true

nodePosition(self, index: int, position: Union[QPointF, QPoint]) → bool

Gets the position of a node in scene coordinates.

Parameters:
  • index – of the node
  • position – the position of the node
Returns:

true if the index is valid and the position is set, false otherwise

nodes(self) → QPolygonF

Returns the nodes the shape consists of.

See also

setNodes()

nodesSize(self) → int

Returns the number of nodes in the shape.

positionAtReferencePoint()
prepareGeometryChange()
readObjectPropertiesFromElement()
readPropertiesFromElement(self, element: QDomElement, document: QDomDocument, context: QgsReadWriteContext) → bool
receivers()
refreshBackgroundColor()
refreshBlendMode()
refreshFrame()
refreshItemPosition()
refreshItemRotation()
refreshItemSize()
refreshOpacity()
removeNode(self, index: int) → bool

Remove a node with specified index from the shape.

rescaleToFitBoundingBox(self)

Rescale the current shape according to the item’s bounding box. Useful when the shape is resized thanks to the rubber band.

sceneEvent()
sceneEventFilter()
selectedNode(self) → int

Returns the currently selected node, or -1 if no node is selected.

sender()
senderSignalIndex()
setDisplayNodes(self, display: bool = True)

Set whether the item’s nodes should be displayed.

setFixedSize()
setMinimumSize()
setNodes(self, nodes: QPolygonF)

Sets the nodes the shape consists of.

See also

nodes()

setSelectedNode(self, index: int) → bool

Selects a node by index.

timerEvent()
topLeftToReferencePoint()
updateBoundingRect(self)

Called when the bounding rect of the item should recalculated. Subclasses should update currentRectangle in their implementations.

updateMicroFocus()
updateSceneRect(self)

Update the current scene rectangle for this item.

wheelEvent()
writeObjectPropertiesToElement()
writePropertiesToElement(self, element: QDomElement, document: QDomDocument, context: QgsReadWriteContext) → bool