Class: QgsLayoutItemPage

class qgis.core.QgsLayoutItemPage

Bases: QgsLayoutItem

Item representing the paper in a layout.

New in version 3.0.

QgsLayoutItemPage(layout: QgsLayout) Constructor for QgsLayoutItemPage, with the specified parent layout.

Methods

accept

param visitor

adjustPointForReferencePosition

Adjusts the specified point at which a reference position of the item sits and returns the top left corner of the item, if reference point were placed at the specified position.

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.

attemptResize

param size

boundingRect

rtype

QRectF

childEvent

connectNotify

contextMenuEvent

create

Returns a new page item for the specified layout.

createCommand

param text

customEvent

decodePageOrientation

Decodes a string representing a page orientation.

disconnectNotify

displayName

rtype

str

dragEnterEvent

dragLeaveEvent

dragMoveEvent

draw

param context

drawBackground

param context

drawDebugRect

Draws a debugging rectangle of the item’s current bounds within the specified painter.

drawFrame

param context

dropEvent

exportLayerBehavior

rtype

QgsLayoutItem.ExportLayerBehavior

focusInEvent

focusOutEvent

framePath

Returns the path to use when drawing the item’s frame or background.

hoverEnterEvent

hoverLeaveEvent

hoverMoveEvent

inputMethodEvent

inputMethodQuery

isSignalConnected

itemChange

keyPressEvent

keyReleaseEvent

mouseDoubleClickEvent

mouseMoveEvent

mousePressEvent

mouseReleaseEvent

orientation

Returns the page orientation.

pageLayout

Returns the page layout for the page, suitable to pass to QPrinter.setPageLayout

pageSize

Returns the size of the page.

pageStyleSymbol

Returns the symbol to use for drawing the page background.

positionAtReferencePoint

Returns the current position (in layout units) of a reference point for the item.

prepareGeometryChange

readObjectPropertiesFromElement

Sets object properties from a DOM element

readPropertiesFromElement

param itemElement

receivers

redraw

refreshBackgroundColor

Refresh item’s background color, considering data defined colors.

refreshBlendMode

Refresh item’s blend mode, considering data defined blend mode.

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.

sceneEvent

sceneEventFilter

sender

senderSignalIndex

setFixedSize

Sets a fixed size for the layout item, which prevents it from being freely resized.

setMinimumSize

Sets the minimum allowed size for the layout item.

setPageSize

Sets the size of the page.

setPageStyleSymbol

Sets the symbol to use for drawing the page background.

timerEvent

topLeftToReferencePoint

Returns the position for the reference point of the item, if the top-left of the item was placed at the specified point.

type

rtype

int

updateMicroFocus

wheelEvent

writeObjectPropertiesToElement

Stores object properties within an XML DOM element.

writePropertiesToElement

param parentElement

Attributes

Landscape

Portrait

UndoPageSymbol

Landscape = 1
class Orientation

Bases: int

Portrait = 0
class UndoCommand

Bases: int

UndoPageSymbol = 3000
accept(self, visitor: QgsStyleEntityVisitorInterface)bool
Parameters

visitor (QgsStyleEntityVisitorInterface) –

Return type

bool

adjustPointForReferencePosition(self, point: Union[QPointF, QPoint], size: QSizeF, reference: QgsLayoutItem.ReferencePoint)QPointF

Adjusts the specified point at which a reference 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

setFixedSize()

See also

setMinimumSize()

attemptResize(self, size: QgsLayoutSize, includesFrame: bool = False)
Parameters
boundingRect(self)QRectF
Return type

QRectF

childEvent(self, QChildEvent)
connectNotify(self, QMetaMethod)
contextMenuEvent(self, QGraphicsSceneContextMenuEvent)
create(layout: QgsLayout)QgsLayoutItemPage

Returns a new page item for the specified layout.

The caller takes responsibility for deleting the returned object.

Parameters

layout (QgsLayout) –

Return type

QgsLayoutItemPage

createCommand(self, text: str, id: int, parent: QUndoCommand = None)QgsAbstractLayoutUndoCommand
Parameters
  • text (str) –

  • id (int) –

  • parent (QUndoCommand = None) –

Return type

QgsAbstractLayoutUndoCommand

customEvent(self, QEvent)
decodePageOrientation(string: str)Tuple[QgsLayoutItemPage.Orientation, bool]

Decodes a string representing a page orientation. If specified, ok will be set to True if string could be successfully interpreted as a page orientation.

Parameters

string (str) –

Return type

Tuple[QgsLayoutItemPage.Orientation, bool]

disconnectNotify(self, QMetaMethod)
displayName(self)str
Return type

str

dragEnterEvent(self, QGraphicsSceneDragDropEvent)
dragLeaveEvent(self, QGraphicsSceneDragDropEvent)
dragMoveEvent(self, QGraphicsSceneDragDropEvent)
draw(self, context: QgsLayoutItemRenderContext)
Parameters

context (QgsLayoutItemRenderContext) –

drawBackground(self, context: QgsRenderContext)
Parameters

context (QgsRenderContext) –

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)
Parameters

context (QgsRenderContext) –

dropEvent(self, QGraphicsSceneDragDropEvent)
exportLayerBehavior(self)QgsLayoutItem.ExportLayerBehavior
Return type

QgsLayoutItem.ExportLayerBehavior

focusInEvent(self, QFocusEvent)
focusOutEvent(self, QFocusEvent)
framePath(self)QPainterPath

Returns the path to use when drawing the item’s frame or background.

See also

drawFrame()

See also

drawBackground()

New in version 3.16.

hoverEnterEvent(self, QGraphicsSceneHoverEvent)
hoverLeaveEvent(self, QGraphicsSceneHoverEvent)
hoverMoveEvent(self, QGraphicsSceneHoverEvent)
inputMethodEvent(self, QInputMethodEvent)
inputMethodQuery(self, Qt.InputMethodQuery)Any
isSignalConnected(self, QMetaMethod)bool
itemChange(self, QGraphicsItem.GraphicsItemChange, Any)Any
keyPressEvent(self, QKeyEvent)
keyReleaseEvent(self, QKeyEvent)
mouseDoubleClickEvent(self, QGraphicsSceneMouseEvent)
mouseMoveEvent(self, QGraphicsSceneMouseEvent)
mousePressEvent(self, QGraphicsSceneMouseEvent)
mouseReleaseEvent(self, QGraphicsSceneMouseEvent)
orientation(self)QgsLayoutItemPage.Orientation

Returns the page orientation.

Note

There is no direct setter for page orientation - use setPageSize() instead.

Return type

QgsLayoutItemPage.Orientation

pageLayout(self)QPageLayout

Returns the page layout for the page, suitable to pass to QPrinter.setPageLayout

New in version 3.20.

Return type

QPageLayout

pageSize(self)QgsLayoutSize

Returns the size of the page.

See also

setPageSize()

Return type

QgsLayoutSize

pageStyleSymbol(self)QgsFillSymbol

Returns the symbol to use for drawing the page background.

New in version 3.10.

Return type

QgsFillSymbol

positionAtReferencePoint(self, reference: QgsLayoutItem.ReferencePoint)QPointF

Returns the current position (in layout units) of a reference point for the item.

prepareGeometryChange(self)
readObjectPropertiesFromElement(self, parentElement: QDomElement, document: QDomDocument, context: QgsReadWriteContext)bool

Sets object properties from a DOM element

Parameters
  • parentElement – is the parent DOM element for the object

  • document – DOM document

  • context – read write context

Returns

True if read was successful

readPropertiesFromElement(self, itemElement: QDomElement, document: QDomDocument, context: QgsReadWriteContext)bool
Parameters
Return type

bool

receivers(self, PYQT_SIGNAL)int
redraw(self)
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.

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.

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.

refreshItemSize(self)

Refreshes an item’s size by rechecking it against any possible item fixed or minimum sizes.

See also

setFixedSize()

See also

setMinimumSize()

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.

sceneEvent(self, QEvent)bool
sceneEventFilter(self, QGraphicsItem, QEvent)bool
sender(self)QObject
senderSignalIndex(self)int
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

fixedSize()

See also

setMinimumSize()

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

minimumSize()

See also

setFixedSize()

setPageSize(self, size: QgsLayoutSize)

Sets the size of the page.

See also

pageSize()

setPageSize(self, size: str, orientation: QgsLayoutItemPage.Orientation = QgsLayoutItemPage.Portrait) -> bool Sets the page size to a known page size, e.g. “A4” and orientation. The known page sizes are managed by QgsPageSizeRegistry. Valid page sizes can be retrieved via QgsPageSizeRegistry.entries(). The function returns True if size was a valid page size and the page size was changed. If False is returned then size could not be matched to a known page size.

See also

pageSize()

Parameters

size (QgsLayoutSize) –

setPageStyleSymbol(self, symbol: QgsFillSymbol)

Sets the symbol to use for drawing the page background.

Ownership of symbol is transferred to the page.

New in version 3.10.

Parameters

symbol (QgsFillSymbol) –

timerEvent(self, QTimerEvent)
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
Return type

int

updateMicroFocus(self)
wheelEvent(self, QGraphicsSceneWheelEvent)
writeObjectPropertiesToElement(self, parentElement: QDomElement, document: QDomDocument, context: QgsReadWriteContext)bool

Stores object properties within an XML DOM element.

Parameters
  • parentElement – is the parent DOM element to store the object’s properties in

  • document – DOM document

  • context – read write context

Returns

True if write was successful

writePropertiesToElement(self, parentElement: QDomElement, document: QDomDocument, context: QgsReadWriteContext)bool
Parameters
  • parentElement (QDomElement) –

  • document (QDomDocument) –

  • context (QgsReadWriteContext) –

Return type

bool