Class: QgsLayoutItemLabel¶
-
class
qgis.core.
QgsLayoutItemLabel
(layout: QgsLayout)¶ Bases:
QgsLayoutItem
Constructor for
QgsLayoutItemLabel
, with the specified parentlayout
.A layout item subclass for text labels.
New in version 3.0.
- Parameters
layout –
-
class
Mode
¶ Bases:
int
-
ModeFont
= 0¶
-
ModeHtml
= 1¶
-
adjustPointForReferencePosition
()¶
-
adjustSizeToText
(self)¶ Resizes the item so that the label’s text fits to the item. Keeps the top left point stationary.
See also
-
applyDataDefinedSize
()¶
-
applyItemSizeConstraint
()¶
-
boundingRect
(self) → QRectF¶ - Return type
QRectF
-
childEvent
()¶
-
connectNotify
()¶
-
contextMenuEvent
()¶
-
create
(layout: QgsLayout) → QgsLayoutItemLabel¶ Returns a new label item for the specified
layout
.The caller takes responsibility for deleting the returned object.
- Parameters
layout (QgsLayout) –
- Return type
-
currentText
(self) → str¶ Returns the text as it appears on the label (with evaluated expressions and other dynamic content).
See also
- Return type
str
-
customEvent
()¶
-
disconnectNotify
()¶
-
displayName
(self) → str¶ - Return type
str
-
dragEnterEvent
()¶
-
dragLeaveEvent
()¶
-
dragMoveEvent
()¶
-
draw
(self, context: QgsLayoutItemRenderContext)¶ - Parameters
context (QgsLayoutItemRenderContext) –
-
drawBackground
()¶
-
drawDebugRect
()¶
-
drawFrame
()¶
-
dropEvent
()¶
-
focusInEvent
()¶
-
focusOutEvent
()¶
-
fontColor
(self) → QColor¶ Returns the label font color.
See also
- Return type
QColor
-
hAlign
(self) → Qt.AlignmentFlag¶ Returns the horizontal alignment of the label.
See also
See also
- Return type
Qt.AlignmentFlag
-
hoverEnterEvent
()¶
-
hoverLeaveEvent
()¶
-
hoverMoveEvent
()¶
-
icon
(self) → QIcon¶ - Return type
QIcon
-
inputMethodEvent
()¶
-
inputMethodQuery
()¶
-
isSignalConnected
()¶
-
itemChange
()¶
-
keyPressEvent
()¶
-
keyReleaseEvent
()¶
-
marginX
(self) → float¶ Returns the horizontal margin between the edge of the frame and the label contents, in layout units.
See also
See also
- Return type
float
-
marginY
(self) → float¶ Returns the vertical margin between the edge of the frame and the label contents, in layout units.
See also
See also
- Return type
float
-
mode
(self) → QgsLayoutItemLabel.Mode¶ Returns the label’s current mode.
See also
- Return type
-
mouseDoubleClickEvent
()¶
-
mouseMoveEvent
()¶
-
mousePressEvent
()¶
-
mouseReleaseEvent
()¶
-
positionAtReferencePoint
()¶
-
prepareGeometryChange
()¶
-
readObjectPropertiesFromElement
()¶
-
readPropertiesFromElement
(self, element: QDomElement, document: QDomDocument, context: QgsReadWriteContext) → bool¶ - Parameters
element (QDomElement) –
document (QDomDocument) –
context (QgsReadWriteContext) –
- Return type
bool
-
receivers
()¶
-
refresh
(self)¶
-
refreshBackgroundColor
()¶
-
refreshBlendMode
()¶
-
refreshFrame
()¶
-
refreshItemPosition
()¶
-
refreshItemRotation
()¶
-
refreshItemSize
()¶
-
refreshOpacity
()¶
-
sceneEvent
()¶
-
sceneEventFilter
()¶
-
sender
()¶
-
senderSignalIndex
()¶
-
setFixedSize
()¶
-
setFont
(self, font: QFont)¶ Sets the label’s current
font
.See also
- Parameters
font (QFont) –
-
setFontColor
(self, color: Union[QColor, Qt.GlobalColor])¶ Sets the label font
color
.See also
- Parameters
color (Union[QColor) –
-
setFrameEnabled
(self, drawFrame: bool)¶ - Parameters
drawFrame (bool) –
-
setFrameStrokeWidth
(self, strokeWidth: QgsLayoutMeasurement)¶ - Parameters
strokeWidth (QgsLayoutMeasurement) –
-
setHAlign
(self, alignment: Qt.AlignmentFlag)¶ Sets the horizontal
alignment
of the label.See also
See also
- Parameters
alignment (Qt.AlignmentFlag) –
-
setMargin
(self, margin: float)¶ Sets the
margin
between the edge of the frame and the label contents. This method sets both the horizontal and vertical margins to the same value. The margins can be individually controlled using the setMarginX() and setMarginY() methods.Margins are set using the current layout units.
See also
See also
- Parameters
margin (float) –
-
setMarginX
(self, margin: float)¶ Sets the horizontal
margin
between the edge of the frame and the label contents, in layout units.See also
See also
- Parameters
margin (float) –
-
setMarginY
(self, margin: float)¶ Sets the vertical
margin
between the edge of the frame and the label contents, in layout units.See also
See also
- Parameters
margin (float) –
-
setMinimumSize
()¶
-
setMode
(self, mode: QgsLayoutItemLabel.Mode)¶ Sets the label’s current
mode
, allowing the label to switch between font based and HTML based rendering.See also
- Parameters
mode (QgsLayoutItemLabel.Mode) –
-
setVAlign
(self, alignment: Qt.AlignmentFlag)¶ Sets for the vertical
alignment
of the label.See also
See also
- Parameters
alignment (Qt.AlignmentFlag) –
-
sizeForText
(self) → QSizeF¶ Returns the required item size (in layout units) for the label’s text to fill the item.
See also
- Return type
QSizeF
-
text
(self) → str¶ Returns the label’s preset text.
See also
See also
- Return type
str
-
timerEvent
()¶
-
topLeftToReferencePoint
()¶
-
type
(self) → int¶ - Return type
int
-
updateMicroFocus
()¶
-
vAlign
(self) → Qt.AlignmentFlag¶ Returns for the vertical alignment of the label.
See also
See also
- Return type
Qt.AlignmentFlag
-
wheelEvent
()¶
-
writeObjectPropertiesToElement
()¶
-
writePropertiesToElement
(self, element: QDomElement, document: QDomDocument, context: QgsReadWriteContext) → bool¶ - Parameters
element (QDomElement) –
document (QDomDocument) –
context (QgsReadWriteContext) –
- Return type
bool