Subgroup: Layout
Class: QgsLayoutTable¶
-
class
qgis.core.
QgsLayoutTable
¶ Bases:
qgis._core.QgsLayoutMultiFrame
A class to display a table in the print layout, and allow the table to span over multiple frames
New in version 3.0: Methods
addFrame
Adds a frame
to the multiframe.backgroundColor
Returns the color used for the background of the table. beginCommand
Starts new undo command for this item. blockSignals
calculateMaxColumnWidths
Calculates the maximum width of text shown in columns. calculateMaxRowHeights
Calculates the maximum height of text shown in rows. cancelCommand
Cancels the current item command and discards it. cellMargin
Returns the margin distance between cell borders and their contents in mm. cellStyle
Returns the cell style for a cell group
.childEvent
children
columns
Returns a reference to the list of QgsLayoutTableColumns shown in the table connectNotify
contentFont
Returns the font used to draw text in table body cells. contentFontColor
Returns the color used to draw text in table body cells. contents
Returns the current contents of the table. contentsContainsRow
Checks whether a table contents contains a given row createCommand
createExpressionContext
Creates an expression context relating to the objects’ current state. createNewFrame
Creates a new frame and adds it to the multi frame and layout. customEvent
customProperties
Return list of keys stored in custom properties for the object. customProperty
Read a custom property from the object. dataDefinedProperties
Returns a reference to the object’s property collection, used for data defined overrides. deleteFrames
Removes and deletes all child frames. deleteLater
disconnect
disconnectNotify
displayName
Returns the multiframe display name. drawHorizontalGridLines
Draws the horizontal grid lines for the table. dumpObjectInfo
dumpObjectTree
dynamicPropertyNames
emptyTableBehavior
Returns the behavior mode for empty tables. emptyTableMessage
Returns the message for empty tables with no content rows. endCommand
Completes the current item command and push it onto the layout’s undo stack. event
eventFilter
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] findNearbyPageBreak
Finds the optimal position to break a frame at. fixedFrameSize
frame
Returns the child frame at a specified index
from the multiframe.frameCount
Returns the number of frames associated with this multiframe. frameIndex
Returns the index of a frame
within the multiframe.frames
Returns a list of all child frames for this multiframe. getTableContents
Fetches the contents used for the cells in the table. gridColor
Returns the color used for grid lines in the table. gridStrokeWidth
Returns the width of grid lines in the table in mm. headerFont
Returns the font used to draw header text in the table. headerFontColor
Returns the color used to draw header text in the table. headerHAlignment
Returns the horizontal alignment for table headers. headerMode
Returns the display mode for headers in the table. horizontalGrid
Returns whether the grid’s horizontal lines are drawn in the table. icon
Returns the item’s icon. inherits
installEventFilter
isSignalConnected
isWidgetType
isWindowType
killTimer
layout
Returns the layout the object is attached to. metaObject
minFrameSize
moveToThread
objectName
parent
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. recalculateFrameRects
Forces a recalculation of all the associated frame’s scene rectangles. recalculateFrameSizes
recalculateTableSize
Recalculates and updates the size of the table and all table frames. receivers
refresh
refreshAttributes
Refreshes the contents shown in the table by querying for new data. refreshDataDefinedProperty
Refreshes a data defined property
for the multi frame by reevaluating the property’s value and redrawing the item with this new value.removeCustomProperty
Remove a custom property from the object. removeEventFilter
removeFrame
Removes a frame by index
from the multiframe.render
resizeMode
Returns the resize mode for the multiframe. rowRange
Calculates a range of rows which should be visible in a given frame. rowsVisible
Calculates how many content rows would be visible within a frame of the specified height. sender
senderSignalIndex
setBackgroundColor
Sets the color
used for background of table.setCellMargin
Sets the margin
distance in mm between cell borders and their contents.setCellStyle
Sets the cell style
for a cellgroup
.setColumns
Replaces the columns in the table with a specified list of QgsLayoutTableColumns. setContentFont
Sets the font
used to draw text in table body cells.setContentFontColor
Sets the color
used to draw text in table body cells.setCustomProperty
Set a custom property for the object. setDataDefinedProperties
Sets the objects’s property collection, used for data defined overrides. setEmptyTableBehavior
Sets the behavior mode
for empty tables with no content rows.setEmptyTableMessage
Sets the message
for empty tables with no content rows.setGridColor
Sets the color
used for grid lines in the table.setGridStrokeWidth
Sets the width
in mm for grid lines in the table.setHeaderFont
Sets the font
used to draw header text in the table.setHeaderFontColor
Sets the color
used to draw header text in the table.setHeaderHAlignment
Sets the horizontal alignment
for table headers.setHeaderMode
Sets the display mode
for headers in the table.setHorizontalGrid
Sets whether the grid’s horizontal lines should be drawn in the table setObjectName
setParent
setProperty
setResizeMode
Sets the resize mode
for the multiframe, and recalculates frame sizes to match.setShowEmptyRows
Sets whether empty rows should be drawn. setShowGrid
Sets whether grid lines should be drawn in the table setVerticalGrid
Sets whether the grid’s vertical lines should be drawn in the table setWrapBehavior
Sets the wrap behavior
for the table, which controls how text within cells is automatically wrapped.showEmptyRows
Returns whether empty rows are drawn in the table. showGrid
Returns whether grid lines are drawn in the table signalsBlocked
startTimer
thread
timerEvent
totalHeight
totalSize
totalWidth
tr
type
Returns unique multiframe type id. update
Forces a redraw of all child frames. uuid
Returns the multiframe identification string. verticalGrid
Returns whether the grid’s vertical lines are drawn in the table. wrapBehavior
Returns the wrap behavior for the table, which controls how text within cells is automatically wrapped. writeObjectPropertiesToElement
writePropertiesToElement
writeXml
Stores the multiframe state in a DOM element. Attributes
AllFrames
AllProperties
BackgroundColor
BlendMode
EvaluatedValue
EvenColumns
EvenRows
ExcludeFromExports
ExtendToNextPage
FirstColumn
FirstFrame
FirstRow
FollowColumn
FrameColor
HeaderCenter
HeaderLeft
HeaderRight
HeaderRow
HeadersOnly
HideTable
ItemHeight
ItemRotation
ItemWidth
LastColumn
LastRow
LegendColumnCount
LegendTitle
MapAtlasMargin
MapLayers
MapRotation
MapScale
MapStylePreset
MapXMax
MapXMin
MapYMax
MapYMin
NoHeaders
NoProperty
NumPages
OddColumns
OddRows
Opacity
OriginalValue
PageNumber
PaperHeight
PaperOrientation
PaperWidth
PictureSource
PictureSvgBackgroundColor
PictureSvgStrokeColor
PictureSvgStrokeWidth
PositionX
PositionY
PresetPaperSize
RepeatOnEveryPage
RepeatUntilFinished
ScalebarFillColor
ScalebarFillColor2
ScalebarLineColor
ScalebarLineWidth
ShowMessage
SourceUrl
TestProperty
Transparency
TruncateText
UndoHtmlBreakDistance
UndoHtmlSource
UndoHtmlStylesheet
UndoNone
UndoTableBackgroundColor
UndoTableCellStyle
UndoTableContentFontColor
UndoTableGridColor
UndoTableGridStrokeWidth
UndoTableHeaderFontColor
UndoTableMargin
UndoTableMaximumFeatures
UseExistingFrames
WrapText
changed
Emitted when the properties of a multi frame have changed, and the GUI item widget must be updated. contentsChanged
Emitted when the contents of the multi frame have changed and the frames must be redrawn. destroyed
destroyed(self, QObject = None) [signal] objectNameChanged
objectNameChanged(self, str) [signal] staticMetaObject
-
AllFrames
= 1¶
-
class
CellStyleGroup
¶ Bases:
int
-
class
EmptyTableMode
¶ Bases:
int
-
EvenColumns
= 1¶
-
EvenRows
= 3¶
-
FirstColumn
= 4¶
-
FirstFrame
= 0¶
-
FirstRow
= 7¶
-
FollowColumn
= 0¶
-
HeaderCenter
= 2¶
-
class
HeaderHAlignment
¶ Bases:
int
-
HeaderLeft
= 1¶
-
class
HeaderMode
¶ Bases:
int
-
HeaderRight
= 3¶
-
HeaderRow
= 6¶
-
HeadersOnly
= 0¶
-
HideTable
= 1¶
-
LastColumn
= 5¶
-
LastRow
= 8¶
-
NoHeaders
= 2¶
-
OddColumns
= 0¶
-
OddRows
= 2¶
-
ShowMessage
= 2¶
-
TruncateText
= 0¶
-
class
WrapBehavior
¶ Bases:
int
-
WrapText
= 1¶
-
backgroundColor
(self) → QColor¶ Returns the color used for the background of the table.
See also
See also
-
calculateMaxColumnWidths
(self) → bool¶ Calculates the maximum width of text shown in columns.
-
calculateMaxRowHeights
(self) → bool¶ Calculates the maximum height of text shown in rows.
-
cellMargin
(self) → float¶ Returns the margin distance between cell borders and their contents in mm.
See also
-
cellStyle
(self, group: QgsLayoutTable.CellStyleGroup) → QgsLayoutTableStyle¶ Returns the cell style for a cell
group
.See also
-
childEvent
()¶
-
columns
(self) → object¶ Returns a reference to the list of QgsLayoutTableColumns shown in the table
See also
-
connectNotify
()¶
-
contentFont
(self) → QFont¶ Returns the font used to draw text in table body cells.
See also
See also
-
contentFontColor
(self) → QColor¶ Returns the color used to draw text in table body cells.
See also
See also
See also
-
contents
(self) → object¶ Returns the current contents of the table. Excludes header cells.
-
contentsContainsRow
(self, contents: object, row: Iterable[Any]) → bool¶ Checks whether a table contents contains a given row
Parameters: - contents – table contents to check
- row – row to check for
Returns: true if contents contains rows
-
customEvent
()¶
-
disconnectNotify
()¶
-
drawHorizontalGridLines
(self, painter: QPainter, firstRow: int, lastRow: int, drawHeaderLines: bool)¶ Draws the horizontal grid lines for the table.
Parameters: - painter – destination painter for grid lines
- firstRow – index corresponding to first row shown in frame
- lastRow – index corresponding to last row shown in frame. If greater than the number of content rows in the
table, then the default row height will be used for the remaining rows. :param drawHeaderLines: set to true to include for the table header
See also
drawVerticalGridLines()
-
emptyTableBehavior
(self) → QgsLayoutTable.EmptyTableMode¶ Returns the behavior mode for empty tables. This property controls how the table is drawn if it contains no content rows.
See also
-
emptyTableMessage
(self) → str¶ Returns the message for empty tables with no content rows. This message is displayed in the table body if the empty table behavior is set to ShowMessage.
See also
See also
-
fixedFrameSize
(self, frameIndex: int = -1) → QSizeF¶
-
getTableContents
(self, contents: object) → bool¶ Fetches the contents used for the cells in the table.
Returns: true if table contents were successfully retrieved. Parameters: contents – QgsLayoutTableContents to store retrieved row data in
-
gridColor
(self) → QColor¶ Returns the color used for grid lines in the table.
See also
See also
See also
-
gridStrokeWidth
(self) → float¶ Returns the width of grid lines in the table in mm.
See also
See also
See also
-
headerFont
(self) → QFont¶ Returns the font used to draw header text in the table.
See also
See also
-
headerFontColor
(self) → QColor¶ Returns the color used to draw header text in the table.
See also
See also
See also
-
headerHAlignment
(self) → QgsLayoutTable.HeaderHAlignment¶ Returns the horizontal alignment for table headers.
See also
-
headerMode
(self) → QgsLayoutTable.HeaderMode¶ Returns the display mode for headers in the table. This property controls if and where headers are shown in the table.
See also
-
horizontalGrid
(self) → bool¶ Returns whether the grid’s horizontal lines are drawn in the table.
See also
See also
See also
See also
-
isSignalConnected
()¶
-
minFrameSize
(self, frameIndex: int = -1) → QSizeF¶
-
readObjectPropertiesFromElement
()¶
-
readPropertiesFromElement
(self, itemElem: QDomElement, doc: QDomDocument, context: QgsReadWriteContext) → bool¶
-
recalculateFrameSizes
(self)¶
-
recalculateTableSize
(self)¶ Recalculates and updates the size of the table and all table frames.
-
receivers
()¶
-
refresh
(self)¶
-
refreshAttributes
(self)¶ Refreshes the contents shown in the table by querying for new data. This also causes the column widths and size of the table to change to accommodate the new data.
See also
adjustFrameToSize()
-
render
(self, context: QgsRenderContext, renderExtent: QRectF, frameIndex: int, itemStyle: QStyleOptionGraphicsItem = None)¶
-
rowRange
(self, frameIndex: int) → Tuple[int, int]¶ Calculates a range of rows which should be visible in a given frame.
Parameters: frameIndex – index number for frame Returns: row range
-
rowsVisible
(self, frameHeight: float, firstRow: int, includeHeader: bool, includeEmptyRows: bool) → int¶ Calculates how many content rows would be visible within a frame of the specified height.
Parameters: - frameHeight – height of frame
- firstRow – index of first row visible in frame (where 0 = first row in table)
- includeHeader – set to true if frame would include a header row
- includeEmptyRows – set to true to also include rows which would be empty in the returned count. For instance,
if the frame would include all table content rows and have space left for extra rows then setting this parameter to true would also include a count of these extra blank rows.
Returns: number of visible content rows (excluding header row) rowsVisible(self, frameIndex: int, firstRow: int, includeEmptyRows: bool) -> int Calculates how many content rows are visible within a given frame.
Parameters: - frameIndex – index number for frame
- firstRow – index of first row visible in frame (where 0 = first row in table)
- includeEmptyRows – set to true to also include rows which would be empty in the returned count. For instance,
if the frame would include all table content rows and have space left for extra rows then setting this parameter to true would also include a count of these extra blank rows.
Returns: number of visible content rows (excludes header rows)
-
sender
()¶
-
senderSignalIndex
()¶
-
setBackgroundColor
(self, color: Union[QColor, Qt.GlobalColor])¶ Sets the
color
used for background of table.See also
See also
-
setCellMargin
(self, margin: float)¶ Sets the
margin
distance in mm between cell borders and their contents.See also
-
setCellStyle
(self, group: QgsLayoutTable.CellStyleGroup, style: QgsLayoutTableStyle)¶ Sets the cell
style
for a cellgroup
.See also
-
setColumns
(self, columns: object)¶ Replaces the columns in the table with a specified list of QgsLayoutTableColumns.
Parameters: columns – list of QgsLayoutTableColumns to show in table. See also
-
setContentFont
(self, font: QFont)¶ Sets the
font
used to draw text in table body cells.See also
See also
-
setContentFontColor
(self, color: Union[QColor, Qt.GlobalColor])¶ Sets the
color
used to draw text in table body cells.See also
See also
See also
-
setEmptyTableBehavior
(self, mode: QgsLayoutTable.EmptyTableMode)¶ Sets the behavior
mode
for empty tables with no content rows.See also
-
setEmptyTableMessage
(self, message: str)¶ Sets the
message
for empty tables with no content rows. This message is displayed in the table body if the empty table behavior is set to ShowMessage.See also
See also
-
setGridColor
(self, color: Union[QColor, Qt.GlobalColor])¶ Sets the
color
used for grid lines in the table.See also
See also
See also
-
setGridStrokeWidth
(self, width: float)¶ Sets the
width
in mm for grid lines in the table.See also
See also
See also
-
setHeaderFont
(self, font: QFont)¶ Sets the
font
used to draw header text in the table.See also
See also
-
setHeaderFontColor
(self, color: Union[QColor, Qt.GlobalColor])¶ Sets the
color
used to draw header text in the table.See also
See also
See also
-
setHeaderHAlignment
(self, alignment: QgsLayoutTable.HeaderHAlignment)¶ Sets the horizontal
alignment
for table headers.See also
-
setHeaderMode
(self, mode: QgsLayoutTable.HeaderMode)¶ Sets the display
mode
for headers in the table. This property controls if and where headers are shown in the table.See also
-
setHorizontalGrid
(self, horizontalGrid: bool)¶ Sets whether the grid’s horizontal lines should be drawn in the table
Parameters: horizontalGrid – set to true to draw grid’s horizontal lines See also
See also
See also
See also
-
setShowEmptyRows
(self, showEmpty: bool)¶ Sets whether empty rows should be drawn. Tables default to hiding empty rows.
Parameters: showEmpty – set to true to show empty rows in the table See also
-
setShowGrid
(self, showGrid: bool)¶ Sets whether grid lines should be drawn in the table
Parameters: showGrid – set to true to show grid lines See also
See also
See also
-
setVerticalGrid
(self, verticalGrid: bool)¶ Sets whether the grid’s vertical lines should be drawn in the table
Parameters: verticalGrid – set to true to draw grid’s vertical lines See also
See also
See also
See also
-
setWrapBehavior
(self, behavior: QgsLayoutTable.WrapBehavior)¶ Sets the wrap
behavior
for the table, which controls how text within cells is automatically wrapped.See also
-
showEmptyRows
(self) → bool¶ Returns whether empty rows are drawn in the table.
See also
-
showGrid
(self) → bool¶ Returns whether grid lines are drawn in the table
See also
See also
See also
-
timerEvent
()¶
-
totalHeight
(self) → float¶
-
totalSize
(self) → QSizeF¶
-
totalWidth
(self) → float¶
-
verticalGrid
(self) → bool¶ Returns whether the grid’s vertical lines are drawn in the table.
See also
See also
See also
See also
-
wrapBehavior
(self) → QgsLayoutTable.WrapBehavior¶ Returns the wrap behavior for the table, which controls how text within cells is automatically wrapped.
See also
-
writeObjectPropertiesToElement
()¶
-
writePropertiesToElement
(self, elem: QDomElement, doc: QDomDocument, context: QgsReadWriteContext) → bool¶
-