Class: QgsAbstractReportSection

class qgis.core.QgsAbstractReportSection

Bases: QgsAbstractLayoutIterator

An abstract base class for QgsReport subsections.

Warning

This is not considered stable API, and may change in future QGIS releases. It is exposed to the Python bindings for unit testing purposes only.

QgsAbstractReportSection(parentSection: Optional[QgsAbstractReportSection] = None) Constructor for QgsAbstractReportSection, attached to the specified parent section. Note that ownership is not transferred to parent.

Methods

accept

Accepts the specified style entity visitor, causing it to visit all style entities associated with the report.

appendChild

Adds a child section, transferring ownership of the section to this section.

beginRender

rtype:

bool

childCount

Returns the number of child sections for this report section.

childSection

Returns the child section at the specified index.

childSections

Returns all child sections for this report section.

clone

Clones the report section.

context

Returns the current context for this section.

copyCommonProperties

Copies the common properties of a report section to a destination section.

count

rtype:

int

description

Returns a user-visible, translated description of the section.

endRender

rtype:

bool

filePath

param baseFilePath:

footer

Returns the footer for the section.

footerEnabled

Returns True if the footer for the section is enabled.

header

Returns the header for the section.

headerEnabled

Returns True if the header for the section is enabled.

icon

Returns an icon representing the section.

insertChild

Inserts a child section at the specified index, transferring ownership of the section to this section.

layout

rtype:

Optional[QgsLayout]

next

rtype:

bool

nextBody

Returns the next body layout to export, or None if no body layout is required this iteration.

parentSection

Returns the parent report section.

prepareFooter

Called just before rendering the section's footer.

prepareHeader

Called just before rendering the section's header.

project

Returns the associated project.

readPropertiesFromElement

Sets section state from a DOM element.

readXml

Sets the item state from a DOM element.

reloadSettings

Refreshes the section when global layout related options change.

removeChild

Removes a child section, deleting it.

removeChildAt

Removes the child section at the specified index, deleting it.

reset

Resets the section, ready for a new iteration.

row

Returns the row number of the section within it's parent section.

setContext

Sets the current context for this section.

setFooter

Sets the footer for the section.

setFooterEnabled

Sets whether the footer for the section is enabled.

setHeader

Sets the header for the section.

setHeaderEnabled

Sets whether the header for the section is enabled.

setParentSection

Sets the parent report section.

type

Returns the section subclass type.

writePropertiesToElement

Stores section state within an XML DOM element.

writeXml

Stores the section state in a DOM element.

Attributes

Body

Children

End

Footer

Header

Body = 1
Children = 2
End = 4
Footer = 3
Header = 0
class SubSection

Bases: int

accept(self, visitor: QgsStyleEntityVisitorInterface | None) bool

Accepts the specified style entity visitor, causing it to visit all style entities associated with the report.

Returns True if the visitor should continue visiting other objects, or False if visiting should be canceled.

Added in version 3.10.

Parameters:

visitor (Optional[QgsStyleEntityVisitorInterface])

Return type:

bool

appendChild(self, section: QgsAbstractReportSection | None)

Adds a child section, transferring ownership of the section to this section.

See also

children()

See also

insertChild()

Parameters:

section (Optional[QgsAbstractReportSection])

beginRender(self) bool
Return type:

bool

childCount(self) int

Returns the number of child sections for this report section. The child sections form the body of the report section.

See also

children()

Return type:

int

childSection(self, index: int) QgsAbstractReportSection | None

Returns the child section at the specified index.

See also

children()

Parameters:

index (int)

Return type:

Optional[QgsAbstractReportSection]

childSections(self) List[QgsAbstractReportSection]

Returns all child sections for this report section. The child sections form the body of the report section.

See also

childCount()

See also

child()

See also

appendChild()

See also

insertChild()

See also

removeChild()

Return type:

List[QgsAbstractReportSection]

clone(self) QgsAbstractReportSection | None

Clones the report section. Ownership of the returned section is transferred to the caller.

Subclasses should call copyCommonProperties() in their clone() implementations.

Return type:

Optional[QgsAbstractReportSection]

context(self) QgsReportSectionContext

Returns the current context for this section.

See also

setContext()

Return type:

QgsReportSectionContext

copyCommonProperties(self, destination: QgsAbstractReportSection | None)

Copies the common properties of a report section to a destination section. This method should be called from clone() implementations.

Parameters:

destination (Optional[QgsAbstractReportSection])

count(self) int
Return type:

int

description(self) str

Returns a user-visible, translated description of the section.

Return type:

str

endRender(self) bool
Return type:

bool

filePath(self, baseFilePath: str | None, extension: str | None) str
Parameters:
  • baseFilePath (Optional[str])

  • extension (Optional[str])

Return type:

str

footer(self) QgsLayout | None

Returns the footer for the section. Note that the footer is only included if footerEnabled() is True.

See also

footerEnabled()

See also

setFooter()

Return type:

Optional[QgsLayout]

footerEnabled(self) bool

Returns True if the footer for the section is enabled.

See also

footer()

See also

setFooter()

Return type:

bool

header(self) QgsLayout | None

Returns the header for the section. Note that the header is only included if headerEnabled() is True.

See also

headerEnabled()

See also

setHeader()

Return type:

Optional[QgsLayout]

headerEnabled(self) bool

Returns True if the header for the section is enabled.

See also

header()

See also

setHeader()

Return type:

bool

icon(self) QIcon

Returns an icon representing the section.

Return type:

QIcon

insertChild(self, index: int, section: QgsAbstractReportSection | None)

Inserts a child section at the specified index, transferring ownership of the section to this section.

See also

children()

See also

appendChild()

Parameters:
layout(self) QgsLayout | None
Return type:

Optional[QgsLayout]

next(self) bool
Return type:

bool

nextBody(self)

Returns the next body layout to export, or None if no body layout is required this iteration.

ok will be set to False if no bodies remain for this section.

parentSection(self) QgsAbstractReportSection | None

Returns the parent report section.

Return type:

Optional[QgsAbstractReportSection]

prepareFooter(self) bool

Called just before rendering the section’s footer. Should return True if the footer is to be included for this section, or False to skip the footerfor the current section.

See also

prepareHeader()

Return type:

bool

prepareHeader(self) bool

Called just before rendering the section’s header. Should return True if the header is to be included for this section, or False to skip the header for the current section.

See also

prepareFooter()

Return type:

bool

project(self) QgsProject | None

Returns the associated project.

Return type:

Optional[QgsProject]

readPropertiesFromElement(self, element: QDomElement, document: QDomDocument, context: QgsReadWriteContext) bool

Sets section state from a DOM element.

See also

readXml()

Parameters:
Return type:

bool

readXml(self, sectionElement: QDomElement, document: QDomDocument, context: QgsReadWriteContext) bool

Sets the item state from a DOM element.

See also

writeXml()

Parameters:
Return type:

bool

reloadSettings(self)

Refreshes the section when global layout related options change.

removeChild(self, section: QgsAbstractReportSection | None)

Removes a child section, deleting it.

See also

children()

Parameters:

section (Optional[QgsAbstractReportSection])

removeChildAt(self, index: int)

Removes the child section at the specified index, deleting it.

See also

children()

Parameters:

index (int)

reset(self)

Resets the section, ready for a new iteration.

row(self) int

Returns the row number of the section within it’s parent section.

Return type:

int

setContext(self, context: QgsReportSectionContext)

Sets the current context for this section.

See also

context()

Parameters:

context (QgsReportSectionContext)

setFooter(self, footer: QgsLayout | None)

Sets the footer for the section. Note that the footer is only included if footerEnabled() is True. Ownership of footer is transferred to the report section.

See also

footerEnabled()

See also

footer()

Parameters:

footer (Optional[QgsLayout])

setFooterEnabled(self, enabled: bool)

Sets whether the footer for the section is enabled.

See also

footerEnabled()

See also

footer()

See also

setFooter()

Parameters:

enabled (bool)

setHeader(self, header: QgsLayout | None)

Sets the header for the section. Note that the header is only included if headerEnabled() is True. Ownership of header is transferred to the report section.

See also

headerEnabled()

See also

header()

Parameters:

header (Optional[QgsLayout])

setHeaderEnabled(self, enabled: bool)

Sets whether the header for the section is enabled.

See also

headerEnabled()

See also

header()

See also

setHeader()

Parameters:

enabled (bool)

setParentSection(self, parent: QgsAbstractReportSection | None)

Sets the parent report section.

Parameters:

parent (Optional[QgsAbstractReportSection])

type(self) str

Returns the section subclass type.

Return type:

str

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

Stores section state within an XML DOM element.

See also

writeXml()

Parameters:
Return type:

bool

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

Stores the section state in a DOM element.

See also

readXml()

Parameters:
Return type:

bool