Class: QgsLayoutItemLabel¶
-
class
qgis.core.
QgsLayoutItemLabel
(layout: QgsLayout)¶ Bases:
qgis._core.QgsLayoutItem
Constructor for QgsLayoutItemLabel, with the specified parent
layout
.A layout item subclass for text labels.
New in version 3.0: Enums
Methods
Resizes the item so that the label’s text fits to the item.
Returns a new label item for the specified
layout
.Returns the text as it appears on the label (with evaluated expressions and other dynamic content).
Returns the label’s current font.
Returns the label font color.
Returns the horizontal alignment of the label.
Returns the horizontal margin between the edge of the frame and the label contents, in layout units.
Returns the vertical margin between the edge of the frame and the label contents, in layout units.
Returns the label’s current mode.
Sets the label’s current
font
.Sets the label font
color
.Sets the horizontal
alignment
of the label.Sets the
margin
between the edge of the frame and the label contents.Sets the horizontal
margin
between the edge of the frame and the label contents, in layout units.Sets the vertical
margin
between the edge of the frame and the label contents, in layout units.Sets the label’s current
mode
, allowing the label to switch between font based and HTML based rendering.Sets the label’s preset
text
.Sets for the vertical
alignment
of the label.Returns the required item size (in layout units) for the label’s text to fill the item.
Returns the label’s preset text.
Returns for the vertical alignment of the label.
Signals
Attributes
-
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¶
-
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.
-
currentText
(self) → str¶ Returns the text as it appears on the label (with evaluated expressions and other dynamic content).
See also
-
customEvent
()¶
-
disconnectNotify
()¶
-
displayName
(self) → str¶
-
dragEnterEvent
()¶
-
dragLeaveEvent
()¶
-
dragMoveEvent
()¶
-
draw
(self, context: QgsLayoutItemRenderContext)¶
-
drawBackground
()¶
-
drawDebugRect
()¶
-
drawFrame
()¶
-
dropEvent
()¶
-
focusInEvent
()¶
-
focusOutEvent
()¶
-
fontColor
(self) → QColor¶ Returns the label font color.
See also
-
hAlign
(self) → Qt.AlignmentFlag¶ Returns the horizontal alignment of the label.
See also
See also
-
hoverEnterEvent
()¶
-
hoverLeaveEvent
()¶
-
hoverMoveEvent
()¶
-
icon
(self) → 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
-
marginY
(self) → float¶ Returns the vertical margin between the edge of the frame and the label contents, in layout units.
See also
See also
-
mouseDoubleClickEvent
()¶
-
mouseMoveEvent
()¶
-
mousePressEvent
()¶
-
mouseReleaseEvent
()¶
-
positionAtReferencePoint
()¶
-
prepareGeometryChange
()¶
-
readObjectPropertiesFromElement
()¶
-
readPropertiesFromElement
(self, element: QDomElement, document: QDomDocument, context: QgsReadWriteContext) → bool¶
-
receivers
()¶
-
refresh
(self)¶
-
refreshBackgroundColor
()¶
-
refreshBlendMode
()¶
-
refreshFrame
()¶
-
refreshItemPosition
()¶
-
refreshItemRotation
()¶
-
refreshItemSize
()¶
-
refreshOpacity
()¶
-
sceneEvent
()¶
-
sceneEventFilter
()¶
-
sender
()¶
-
senderSignalIndex
()¶
-
setFixedSize
()¶
-
setFontColor
(self, color: Union[QColor, Qt.GlobalColor])¶ Sets the label font
color
.See also
-
setFrameEnabled
(self, drawFrame: bool)¶
-
setFrameStrokeWidth
(self, strokeWidth: QgsLayoutMeasurement)¶
-
setHAlign
(self, alignment: Qt.AlignmentFlag)¶ Sets the horizontal
alignment
of the label.See also
See also
-
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
-
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
-
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
-
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
-
setVAlign
(self, alignment: Qt.AlignmentFlag)¶ Sets for the vertical
alignment
of the label.See also
See also
-
sizeForText
(self) → QSizeF¶ Returns the required item size (in layout units) for the label’s text to fill the item.
See also
-
text
(self) → str¶ Returns the label’s preset text.
See also
See also
-
timerEvent
()¶
-
topLeftToReferencePoint
()¶
-
type
(self) → int¶
-
updateMicroFocus
()¶
-
vAlign
(self) → Qt.AlignmentFlag¶ Returns for the vertical alignment of the label.
See also
See also
-
wheelEvent
()¶
-
writeObjectPropertiesToElement
()¶
-
writePropertiesToElement
(self, element: QDomElement, document: QDomDocument, context: QgsReadWriteContext) → bool¶
-
class