Subgroup: Layout
Class: QgsLayoutItem¶
-
class
qgis.core.
QgsLayoutItem
¶ Bases:
qgis._core.QgsLayoutObject
,PyQt5.QtWidgets.QGraphicsRectItem
,qgis._core.QgsLayoutUndoObjectInterface
Base class for graphical items within a QgsLayout.
New in version 3.0: Methods
acceptDrops
acceptHoverEvents
acceptTouchEvents
acceptedMouseButtons
adjustPointForReferencePosition
Adjusts the specified point
at which areference
position of the item sits and returns the top left corner of the item, if reference point were placed at the specified position.advance
applyDataDefinedSize
Applies any present data defined size overrides to the specified layout size
.applyItemSizeConstraint
Applies any item-specific size constraint handling to a given targetSize
in layout units.attemptMove
Attempts to move the item to a specified point
.attemptMoveBy
Attempts to shift the item’s position by a specified deltaX
anddeltaY
, 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
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
deviceTransform
disconnect
disconnectNotify
displayName
Get item display name. dragEnterEvent
dragLeaveEvent
dragMoveEvent
draw
Draws the item’s contents using the specified render context
.drawBackground
Draws the background for the item. drawDebugRect
Draws a debugging rectangle of the item’s current bounds within the specified painter. drawFrame
Draws the frame around the item. 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
Returns the estimated amount the item’s frame bleeds outside the item’s actual rectangle. 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
anddy
in layout units.moveToThread
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
Returns the current position (in layout units) of a reference
point for the item.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
Sets item state from a DOM element. 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
Refresh item’s background color, considering data defined colors. refreshBlendMode
Refresh item’s blend mode, considering data defined blend mode. refreshDataDefinedProperty
Refreshes a data defined property
for the item by reevaluating the property’s value and redrawing the item with this new value.refreshFrame
Refresh item’s frame, considering data defined colors and frame size. refreshItemPosition
Refreshes an item’s position by rechecking it against any possible overrides such as data defined positioning. refreshItemRotation
Refreshes an item’s rotation by rechecking it against any possible overrides such as data defined rotation. refreshItemSize
Refreshes an item’s size by rechecking it against any possible item fixed or minimum sizes. refreshOpacity
Refresh item’s opacity, considering data defined opacity. removeCustomProperty
Remove a custom property from the object. removeEventFilter
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. 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
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. setEnabled
setExcludeFromExports
Sets whether the item should be excluded from layout exports and prints. setFiltersChildEvents
setFixedSize
Sets a fixed size
for the layout item, which prevents it from being freely resized.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
Sets the minimum allowed size
for the layout item.setMoveContentPreviewOffset
Sets temporary offset for the item, by a specified dx
anddy
in layout units.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. 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
Returns the position for the reference point of the item, if the top-left of the item was placed at the specified point
.topLevelItem
topLevelWidget
tr
transform
transformOriginPoint
transformations
type
Returns a unique graphics item type identifier. ungrabKeyboard
ungrabMouse
unsetCursor
update
update(self, float, float, float, float) updateMicroFocus
uuid
Returns the item identification string. wheelEvent
window
writeObjectPropertiesToElement
writePropertiesToElement
Stores item state within an XML DOM element. 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
-
LowerLeft
= 6¶
-
LowerMiddle
= 7¶
-
LowerRight
= 8¶
-
Middle
= 4¶
-
MiddleLeft
= 3¶
-
MiddleRight
= 5¶
-
class
ReferencePoint
¶ Bases:
int
-
UndoArrowHeadFillColor
= 68¶
-
UndoArrowHeadStrokeColor
= 69¶
-
UndoArrowHeadWidth
= 67¶
-
UndoArrowStrokeWidth
= 66¶
-
UndoAtlasMargin
= 12¶
-
UndoBackgroundColor
= 5¶
-
class
UndoCommand
¶ Bases:
int
-
UndoCustomCommand
= 70¶
-
UndoGridFramePenColor
= 16¶
-
UndoIncrementalMove
= 1¶
-
UndoIncrementalResize
= 2¶
-
UndoLabelFont
= 29¶
-
UndoLabelFontColor
= 31¶
-
UndoLabelMargin
= 30¶
-
UndoLabelText
= 28¶
-
UndoLegendBoxSpace
= 44¶
-
UndoLegendColumnCount
= 33¶
-
UndoLegendColumnSpace
= 45¶
-
UndoLegendFontColor
= 43¶
-
UndoLegendGroupFont
= 50¶
-
UndoLegendGroupSpace
= 39¶
-
UndoLegendIconSymbolSpace
= 42¶
-
UndoLegendItemFont
= 52¶
-
UndoLegendLayerFont
= 51¶
-
UndoLegendLayerSpace
= 40¶
-
UndoLegendLineSpacing
= 46¶
-
UndoLegendRasterStrokeColor
= 48¶
-
UndoLegendRasterStrokeWidth
= 47¶
-
UndoLegendSymbolHeight
= 35¶
-
UndoLegendSymbolSpace
= 41¶
-
UndoLegendSymbolWidth
= 34¶
-
UndoLegendText
= 32¶
-
UndoLegendTitleFont
= 49¶
-
UndoLegendTitleSpaceBottom
= 38¶
-
UndoLegendWmsLegendHeight
= 37¶
-
UndoLegendWmsLegendWidth
= 36¶
-
UndoMapAnnotationDistance
= 19¶
-
UndoMapGridAnnotationFontColor
= 20¶
-
UndoMapGridFrameFill1Color
= 17¶
-
UndoMapGridFrameFill2Color
= 18¶
-
UndoMapGridLineSymbol
= 21¶
-
UndoMapGridMarkerSymbol
= 22¶
-
UndoMapRotation
= 13¶
-
UndoNodeMove
= 11¶
-
UndoNone
= -1¶
-
UndoOpacity
= 6¶
-
UndoOverviewStyle
= 15¶
-
UndoPictureFillColor
= 24¶
-
UndoPictureNorthOffset
= 27¶
-
UndoPictureRotation
= 23¶
-
UndoPictureStrokeColor
= 25¶
-
UndoPictureStrokeWidth
= 26¶
-
UndoRotation
= 8¶
-
UndoScaleBarBoxContentSpace
= 65¶
-
UndoScaleBarFillColor
= 59¶
-
UndoScaleBarFillColor2
= 60¶
-
UndoScaleBarFontColor
= 58¶
-
UndoScaleBarHeight
= 57¶
-
UndoScaleBarLabelBarSize
= 64¶
-
UndoScaleBarLineWidth
= 53¶
-
UndoScaleBarMapUnitsSegment
= 63¶
-
UndoScaleBarSegmentSize
= 54¶
-
UndoScaleBarSegments
= 56¶
-
UndoScaleBarSegmentsLeft
= 55¶
-
UndoScaleBarStrokeColor
= 61¶
-
UndoScaleBarUnitText
= 62¶
-
UndoSetId
= 7¶
-
UndoShapeCornerRadius
= 10¶
-
UndoShapeStyle
= 9¶
-
UndoStrokeColor
= 3¶
-
UndoStrokeWidth
= 4¶
-
UndoZoomContent
= 14¶
-
UpperLeft
= 0¶
-
UpperMiddle
= 1¶
-
UpperRight
= 2¶
-
adjustPointForReferencePosition
(self, point: Union[QPointF, QPoint], size: QSizeF, reference: QgsLayoutItem.ReferencePoint) → QPointF¶ Adjusts the specified
point
at which areference
position of the item sits and returns the top left corner of the item, if reference point were placed at the specified position.
-
applyDataDefinedSize
(self, size: QgsLayoutSize) → QgsLayoutSize¶ Applies any present data defined size overrides to the specified layout
size
.
-
applyItemSizeConstraint
(self, targetSize: QSizeF) → QSizeF¶ Applies any item-specific size constraint handling to a given
targetSize
in layout units. Subclasses can override this method if they need to apply advanced logic regarding item sizes, which cannot be covered by setFixedSize() or setMinimumSize(). Item size constraints are applied after fixed, minimum and data defined size constraints.See also
See also
-
attemptMove
(self, point: QgsLayoutPoint, useReferencePoint: bool = True, includesFrame: bool = False, page: int = -1)¶ Attempts to move the item to a specified
point
.If
useReferencePoint
is true, this method will respect the item’s reference point, in that the item will be moved so that its current reference point is placed at the specified target point.If
useReferencePoint
is false, the item will be moved so thatpoint
falls at the top-left corner of the item.If
includesFrame
is true, then the position specified bypoint
represents the point at which to place the outside of the item’s frame.If
page
is not left at the default -1 value, then the position specified bypoint
refers to the relative position on the corresponding layoutpage
(where apage
of 0 represents the first page).Note that the final position of the item may not match the specified target position, as data defined item position may override the specified value.
See also
See also
See also
See also
-
attemptMoveBy
(self, deltaX: float, deltaY: float)¶ Attempts to shift the item’s position by a specified
deltaX
anddeltaY
, in layout units.Note that the final position of the item may not match the specified offsets, as data defined item position and size may override the specified value.
See also
See also
See also
See also
-
attemptResize
(self, size: QgsLayoutSize, includesFrame: bool = False)¶ Attempts to resize the item to a specified target
size
. Note that the final size of the item may not match the specified target size, as items with a fixed or minimum size will place restrictions on the allowed item size. Data defined item size overrides will also override the specified target size.If
includesFrame
is true, then the size specified bysize
includes the item’s frame.See also
See also
See also
See also
-
attemptSetSceneRect
(self, rect: QRectF, includesFrame: bool = False)¶ Attempts to update the item’s position and size to match the passed
rect
in layout coordinates.If
includesFrame
is true, then the position and size specified byrect
represents the position and size at for the outside of the item’s frame.Note that the final position and size of the item may not match the specified target rect, as data defined item position and size may override the specified value.
See also
See also
See also
See also
-
backgroundColor
(self) → QColor¶ Returns the background color for this item. This is only used if hasBackground() returns true.
See also
See also
-
beginCommand
(self, commandText: str, command: QgsLayoutItem.UndoCommand = QgsLayoutItem.UndoNone)¶ Starts new undo command for this item. The
commandText
should be a capitalized, imperative tense description (e.g. “Add Map Item”). If specified, multiple consecutive commands for this item with the samecommand
will be collapsed into a single undo command in the layout history.See also
See also
-
blendMode
(self) → QPainter.CompositionMode¶ Returns the item’s composition blending mode.
See also
-
cancelCommand
(self)¶ Cancels the current item command and discards it.
See also
See also
-
childEvent
()¶
-
cleanup
(self)¶ Called just before a batch of items are deleted, allowing them to run cleanup tasks.
-
connectNotify
()¶
-
containsAdvancedEffects
(self) → bool¶ Returns true if the item contains contents with blend modes or transparency effects which can only be reproduced by rastering the item.
Subclasses should ensure that implemented overrides of this method also check the base class result.
See also
-
contextMenuEvent
()¶
-
createCommand
(self, text: str, id: int, parent: QUndoCommand = None) → QgsAbstractLayoutUndoCommand¶
-
createExpressionContext
(self) → QgsExpressionContext¶
-
customEvent
()¶
-
disconnectNotify
()¶
-
displayName
(self) → str¶ Get item display name. This is the item’s id if set, and if not, a user-friendly string identifying item type.
See also
See also
-
dragEnterEvent
()¶
-
dragLeaveEvent
()¶
-
dragMoveEvent
()¶
-
draw
(self, context: QgsRenderContext, itemStyle: QStyleOptionGraphicsItem = None)¶ Draws the item’s contents using the specified render
context
. Note that the context’s painter has been scaled so that painter units are pixels. Use the QgsRenderContext methods to convert from millimeters or other units to the painter’s units.
-
drawBackground
(self, context: QgsRenderContext)¶ Draws the background for the item.
-
drawDebugRect
(self, painter: QPainter)¶ Draws a debugging rectangle of the item’s current bounds within the specified painter.
Parameters: painter – destination QPainter
-
drawFrame
(self, context: QgsRenderContext)¶ Draws the frame around the item.
-
dropEvent
()¶
-
endCommand
(self)¶ Completes the current item command and push it onto the layout’s undo stack.
See also
See also
-
estimatedFrameBleed
(self) → float¶ Returns the estimated amount the item’s frame bleeds outside the item’s actual rectangle. For instance, if the item has a 2mm frame stroke, then 1mm of this frame is drawn outside the item’s rect. In this case the return value will be 1.0.
Returned values are in layout units.
See also
-
excludeFromExports
(self) → bool¶ Returns whether the item should be excluded from layout exports and prints.
See also
-
finalizeRestoreFromXml
(self)¶ Called after all pending items have been restored from XML. 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. a scalebar can use this to connect to its linked map item after restoration from XML.
See also
-
fixedSize
(self) → QgsLayoutSize¶ Returns the fixed size of the item, if applicable, or an empty size if item can be freely resized.
See also
See also
-
focusInEvent
()¶
-
focusOutEvent
()¶
-
frameChanged
¶ Emitted if the item’s frame style changes. [signal]
-
frameEnabled
(self) → bool¶ Returns true if the item includes a frame.
See also
See also
See also
See also
-
frameJoinStyle
(self) → Qt.PenJoinStyle¶ Returns the join style used for drawing the item’s frame.
See also
See also
See also
See also
-
frameStrokeColor
(self) → QColor¶ Returns the frame’s stroke color. This is only used if frameEnabled() returns true.
See also
See also
See also
See also
-
frameStrokeWidth
(self) → QgsLayoutMeasurement¶ Returns the frame’s stroke width. This is only used if frameEnabled() returns true.
See also
See also
See also
See also
-
hasBackground
(self) → bool¶ Returns true if the item has a background.
See also
See also
-
hoverEnterEvent
()¶
-
hoverLeaveEvent
()¶
-
hoverMoveEvent
()¶
-
icon
(self) → QIcon¶ Returns the item’s icon.
-
id
(self) → str¶ Returns the item’s ID name. This is not necessarily unique, and duplicate ID names may exist for a layout.
See also
See also
-
inputMethodEvent
()¶
-
inputMethodQuery
()¶
-
invalidateCache
(self)¶ Forces a deferred update of any cached image the item uses.
-
isGroupMember
(self) → bool¶ Returns true if the item is part of a QgsLayoutItemGroup group.
See also
See also
-
isLocked
(self) → bool¶ Returns true if the item is locked, and cannot be interacted with using the mouse.
See also
See also
-
isSignalConnected
()¶
-
itemChange
()¶
-
itemOpacity
(self) → float¶ Returns the item’s opacity. This method should be used instead of QGraphicsItem.opacity() as any data defined overrides will be respected.
Returns: opacity as double between 1.0 (opaque) and 0 (transparent). See also
-
itemRotation
(self) → float¶ Returns the current rotation for the item, in degrees clockwise.
Note that this method will always return the user-set rotation for the item, which may differ from the current item rotation (if data defined rotation settings are present). Use QGraphicsItem.rotation() to obtain the current item rotation.
See also
-
keyPressEvent
()¶
-
keyReleaseEvent
()¶
-
lockChanged
¶ Emitted if the item’s lock status changes.
See also
See also
setLocked()
[signal]
-
minimumSize
(self) → QgsLayoutSize¶ Returns the minimum allowed size of the item, if applicable, or an empty size if item can be freely resized.
See also
See also
-
mouseDoubleClickEvent
()¶
-
mouseMoveEvent
()¶
-
mousePressEvent
()¶
-
mouseReleaseEvent
()¶
-
moveContent
(self, dx: float, dy: float)¶ Moves the content of the item, by a specified
dx
anddy
in layout units. The default implementation has no effect.See also
See also
-
numberExportLayers
(self) → int¶ Returns the number of layers that this item requires for exporting during layered exports (e.g. SVG). Returns 0 if this item is to be placed on the same layer as the previous item, 1 if it should be placed on its own layer, and >1 if it requires multiple export layers.
Items which require multiply layers should check QgsLayoutContext.currentExportLayer() during their rendering to determine which layer should be drawn.
-
page
(self) → int¶ Returns the page the item is currently on, with the first page returning 0.
See also
-
pagePos
(self) → QPointF¶ Returns the item’s position (in layout units) relative to the top left corner of its current page.
See also
See also
-
pagePositionWithUnits
(self) → QgsLayoutPoint¶ Returns the item’s position (in item units) relative to the top left corner of its current page.
See also
See also
-
paint
(self, painter: QPainter, itemStyle: QStyleOptionGraphicsItem, pWidget: QWidget)¶ Handles preparing a paint surface for the layout item and painting the item’s content. Derived classes must not override this method, but instead implement the pure virtual method QgsLayoutItem.draw.
-
parentGroup
(self) → QgsLayoutItemGroup¶ Returns the item’s parent group, if the item is part of a QgsLayoutItemGroup group.
See also
See also
-
positionAtReferencePoint
(self, reference: QgsLayoutItem.ReferencePoint) → QPointF¶ Returns the current position (in layout units) of a
reference
point for the item.
-
positionWithUnits
(self) → QgsLayoutPoint¶ Returns the item’s current position, including units. The position returned is the position of the item’s reference point, which may not necessarily be the top left corner of the item.
See also
See also
See also
-
prepareGeometryChange
()¶
-
readObjectPropertiesFromElement
()¶
-
readPropertiesFromElement
(self, element: QDomElement, document: QDomDocument, context: QgsReadWriteContext) → bool¶ Sets item state from a DOM element.
Parameters: - element – is the DOM element for the item
- document – DOM document
- context – read write context
Note that item subclasses should not rely on all other items being present in the layout at the time this method is called. Instead, any connections and links to other items must be made in the finalizeRestoreFromXml() method. E.g. when restoring a scalebar, the connection to the linked map’s signals should be implemented in finalizeRestoreFromXml(), not readPropertiesFromElement().
See also
See also
-
readXml
(self, itemElement: QDomElement, document: QDomDocument, context: QgsReadWriteContext) → bool¶ Sets the item state from a DOM element.
Parameters: - itemElement – is the DOM node corresponding to item (e.g. ‘LayoutItem’ element)
- document – DOM document
- context – read write context
Note that item subclasses should not rely on all other items being present in the layout at the time this method is called. Instead, any connections and links to other items must be made in the finalizeRestoreFromXml() method. E.g. when restoring a scalebar, the connection to the linked map’s signals should be implemented in finalizeRestoreFromXml(), not readXml().
See also
See also
-
receivers
()¶
-
rectWithFrame
(self) → QRectF¶ Returns the item’s rectangular bounds, including any bleed caused by the item’s frame. The bounds are returned in the item’s coordinate system (see Qt’s QGraphicsItem docs for more details about QGraphicsItem coordinate systems). The results differ from Qt’s rect() function, as rect() makes no allowances for the portion of outlines which are drawn outside of the item.
See also
-
redraw
(self)¶ Triggers a redraw (update) of the item.
-
referencePoint
(self) → QgsLayoutItem.ReferencePoint¶ Returns the reference point for positioning of the layout item. This point is also fixed during resizing of the item, and any size changes will be performed so that the position of the reference point within the layout remains unchanged.
See also
-
refresh
(self)¶ Refreshes the item, causing a recalculation of any property overrides and recalculation of its position and size.
-
refreshBackgroundColor
(self, updateItem: bool = True)¶ Refresh item’s background color, considering data defined colors. If
updateItem
is set to false, the item will not be automatically updated after the frame color is set and a later call to update() must be made.
-
refreshBlendMode
(self)¶ Refresh item’s blend mode, considering data defined blend mode.
-
refreshDataDefinedProperty
(self, property: QgsLayoutObject.DataDefinedProperty = QgsLayoutObject.AllProperties)¶ Refreshes a data defined
property
for the item by reevaluating the property’s value and redrawing the item with this new value. Ifproperty
is set to QgsLayoutObject.AllProperties then all data defined properties for the item will be refreshed.
-
refreshFrame
(self, updateItem: bool = True)¶ Refresh item’s frame, considering data defined colors and frame size. If
updateItem
is set to false, the item will not be automatically updated after the frame is set and a later call to update() must be made.
-
refreshItemPosition
(self)¶ Refreshes an item’s position by rechecking it against any possible overrides such as data defined positioning.
See also
-
refreshItemRotation
(self, origin: Union[QPointF, QPoint] = None)¶ Refreshes an item’s rotation by rechecking it against any possible overrides such as data defined rotation.
The optional
origin
point specifies the origin (in item coordinates) around which the rotation should be applied.See also
See also
-
refreshItemSize
(self)¶ Refreshes an item’s size by rechecking it against any possible item fixed or minimum sizes.
See also
See also
See also
-
refreshOpacity
(self, updateItem: bool = True)¶ Refresh item’s opacity, considering data defined opacity. If
updateItem
is set to false the item will not be automatically updated after the opacity is set and a later call to update() must be made.
-
requiresRasterization
(self) → bool¶ Returns true if the item is drawn in such a way that forces the whole layout to be rasterized when exporting to vector formats.
See also
-
rotateItem
(self, angle: float, transformOrigin: Union[QPointF, QPoint])¶ Rotates the item by a specified
angle
in degrees clockwise around a specified reference point.See also
See also
-
rotationChanged
¶ Emitted on item rotation change. [signal]
-
sceneEvent
()¶
-
sceneEventFilter
()¶
-
sender
()¶
-
senderSignalIndex
()¶
-
setBackgroundColor
(self, color: Union[QColor, Qt.GlobalColor])¶ Sets the background
color
for this item.See also
See also
-
setBackgroundEnabled
(self, drawBackground: bool)¶ Sets whether this item has a background drawn under it or not.
See also
See also
-
setBlendMode
(self, mode: QPainter.CompositionMode)¶ Sets the item’s composition blending
mode
.See also
-
setExcludeFromExports
(self, exclude: bool)¶ Sets whether the item should be excluded from layout exports and prints.
See also
-
setFixedSize
(self, size: QgsLayoutSize)¶ Sets a fixed
size
for the layout item, which prevents it from being freely resized. Set an empty size if item can be freely resized.See also
See also
-
setFrameEnabled
(self, drawFrame: bool)¶ Sets whether this item has a frame drawn around it or not.
See also
See also
See also
See also
-
setFrameJoinStyle
(self, style: Qt.PenJoinStyle)¶ Sets the join
style
used when drawing the item’s frame.See also
See also
See also
See also
-
setFrameStrokeColor
(self, color: Union[QColor, Qt.GlobalColor])¶ Sets the frame stroke
color
.See also
See also
See also
See also
-
setFrameStrokeWidth
(self, width: QgsLayoutMeasurement)¶ Sets the frame stroke
width
.See also
See also
See also
See also
-
setId
(self, id: str)¶ Set the item’s
id
name. This is not necessarily unique, and duplicate ID names may exist for a layout.See also
See also
-
setItemOpacity
(self, opacity: float)¶ Sets the item’s
opacity
. This method should be used instead of QGraphicsItem.setOpacity() as any data defined overrides will be respected.Parameters: opacity – double between 1.0 (opaque) and 0 (transparent). See also
-
setItemRotation
(self, rotation: float, adjustPosition: bool = True)¶ Sets the layout item’s
rotation
, in degrees clockwise.If
adjustPosition
is true, then this rotation occurs around the center of the item. IfadjustPosition
is false, rotation occurs around the item origin.See also
See also
-
setLocked
(self, locked: bool)¶ Sets whether the item is
locked
, preventing mouse interactions with the item.See also
See also
-
setMinimumSize
(self, size: QgsLayoutSize)¶ Sets the minimum allowed
size
for the layout item. Set an empty size if item can be freely resized.See also
See also
-
setMoveContentPreviewOffset
(self, dx: float, dy: float)¶ Sets temporary offset for the item, by a specified
dx
anddy
in layout units. This is useful for live updates when moving item content in aQgsLayoutView
. The default implementation has no effect.See also
-
setParentGroup
(self, group: QgsLayoutItemGroup)¶ Sets the item’s parent
group
.See also
See also
-
setReferencePoint
(self, point: QgsLayoutItem.ReferencePoint)¶ Sets the reference
point
for positioning of the layout item. This point is also fixed during resizing of the item, and any size changes will be performed so that the position of the reference point within the layout remains unchanged.See also
-
setSelected
(self, selected: bool)¶ Sets whether the item should be selected.
-
setVisibility
(self, visible: bool)¶ Sets whether the item is
visible
.Note
QGraphicsItem.setVisible should not be called directly on a QgsLayoutItem, as some item types (e.g., groups) need to override the visibility toggle.
-
shouldDrawItem
(self) → bool¶ Returns whether the item should be drawn in the current context.
-
sizePositionChanged
¶ Emitted when the item’s size or position changes. [signal]
-
sizeWithUnits
(self) → QgsLayoutSize¶ Returns the item’s current size, including units.
See also
See also
-
templateUuid
(self) → str¶ Returns the item’s original identification string. This may differ from the item’s uuid() for items which have been added to an existing layout from a template. In this case templateUuid() returns the original item UUID at the time the template was created, while uuid() returns the current instance of the item’s unique identifier.
See also
-
timerEvent
()¶
-
topLeftToReferencePoint
(self, point: QgsLayoutPoint) → QgsLayoutPoint¶ Returns the position for the reference point of the item, if the top-left of the item was placed at the specified
point
.
-
type
(self) → int¶ Returns a unique graphics item type identifier.
Plugin based subclasses should return an identifier greater than QgsLayoutItemRegistry.PluginItem.
-
updateMicroFocus
()¶
-
uuid
(self) → str¶ Returns the item identification string. This is a unique random string set for the item upon creation.
Note
There is no corresponding setter for the uuid - it’s created automatically.
See also
See also
See also
-
wheelEvent
()¶
-
writeObjectPropertiesToElement
()¶
-
writePropertiesToElement
(self, element: QDomElement, document: QDomDocument, context: QgsReadWriteContext) → bool¶ Stores item state within an XML DOM element.
Parameters: - element – is the DOM element to store the item’s properties in
- document – DOM document
- context – read write context
See also
See also
-
writeXml
(self, parentElement: QDomElement, document: QDomDocument, context: QgsReadWriteContext) → bool¶ Stores the item state in a DOM element.
Parameters: - parentElement – parent DOM element (e.g. ‘Layout’ element)
- document – DOM document
- context – read write context
See also
-
zoomContent
(self, factor: float, point: Union[QPointF, QPoint])¶ Zooms content of item. Does nothing by default.
Parameters: - factor – zoom factor, where > 1 results in a zoom in and < 1 results in a zoom out
- point – item point for zoom center
See also
-