- class QLegend#
The
QLegend
class displays the legend of a chart. More…Synopsis#
Properties#
alignmentᅟ
- How the legend is aligned with the chartbackgroundVisibleᅟ
- Whether the legend background is visibleborderColorᅟ
- Line color of the legendcolorᅟ
- Background (brush) color of the legendfontᅟ
- Of the markers used by the legendlabelColorᅟ
- Color of the brush used to draw labelsreverseMarkersᅟ
- Whether reverse order is used for the markers in the legendshowToolTipsᅟ
- Whether tooltips are shown when the text is truncated
Methods#
def
alignment()
def
attachToChart()
def
borderColor()
def
brush()
def
color()
def
isInteractive()
def
labelBrush()
def
labelColor()
def
markerShape()
def
markers()
def
pen()
def
reverseMarkers()
def
setAlignment()
def
setBorderColor()
def
setBrush()
def
setColor()
def
setInteractive()
def
setLabelBrush()
def
setLabelColor()
def
setMarkerShape()
def
setPen()
def
showToolTips()
Signals#
Note
This documentation may contain snippets that were automatically translated from C++ to Python. We always welcome contributions to the snippet translation. If you see an issue with the translation, you can also let us know by creating a ticket on https:/bugreports.qt.io/projects/PYSIDE
Detailed Description#
A legend is a graphical object that displays the legend of a chart. The legend state is updated by
QChart
when series change. By default, the legend is attached to the chart, but it can be detached to make it independent of chart layout. Legend objects cannot be created or deleted, but they can be referenced via theQChart
class.See also
- class MarkerShape#
This enum describes the shape used when rendering legend marker items.
Constant
Description
QLegend.MarkerShapeDefault
Default shape determined by
QLegend
is used for the marker. This value is supported only for individualQLegendMarker
items.QLegend.MarkerShapeRectangle
Rectangular markers are used. Marker size is determined by font size.
QLegend.MarkerShapeCircle
Circular markers are used. Marker size is determined by font size.
QLegend.MarkerShapeRotatedRectangle
Rotated rectangle shaped markers are used. Marker size is determined by font size.
QLegend.MarkerShapeTriangle
Triangular markers are used. Marker size is determined by font size.
QLegend.MarkerShapeStar
Star shaped markers are used. Marker size is determined by font size.
QLegend.MarkerShapePentagon
Pentagon shaped markers are used. Marker size is determined by font size.
QLegend.MarkerShapeFromSeries
The marker shape is determined by the series. In case of a scatter series, the legend marker looks like a scatter dot and is the same size as the dot. In case of a line or spline series, the legend marker looks like a small segment of the line. For other series types, rectangular markers are shown. If a
lightMarker
is specified for a series, thelightMarker
will be shown and its size will be determined by the series marker size.See also
Note
Properties can be used directly when
from __feature__ import true_property
is used or via accessor functions otherwise.- property alignmentᅟ: Combination of Qt.AlignmentFlag#
This property holds How the legend is aligned with the chart..
Can be Qt::AlignTop, Qt::AlignBottom, Qt::AlignLeft, Qt::AlignRight. If you set more than one flag, the result is undefined.
- Access functions:
- property backgroundVisibleᅟ: bool#
This property holds Whether the legend background is visible..
- Access functions:
This property holds The line color of the legend..
- Access functions:
This property holds The background (brush) color of the legend..
If you change the color of the legend, the style of the legend brush is set to Qt::SolidPattern.
- Access functions:
Signal
colorChanged()
This property holds The font of the markers used by the legend..
- Access functions:
Signal
fontChanged()
This property holds The color of the brush used to draw labels..
- Access functions:
- property markerShapeᅟ: QLegend.MarkerShape#
The default shape of the legend markers. The default value is
MarkerShapeRectangle
.- Access functions:
- property reverseMarkersᅟ: bool#
This property holds Whether reverse order is used for the markers in the legend..
This property is
false
by default.- Access functions:
- property showToolTipsᅟ: bool#
This property holds Whether tooltips are shown when the text is truncated..
This property is
false
by default.- Access functions:
- alignment()#
- Return type:
Combination of
AlignmentFlag
See also
Getter of property
alignmentᅟ
.- attachToChart()#
Attaches the legend to a chart. The chart may adjust the layout of the legend.
- attachedToChartChanged(attachedToChart)#
- Parameters:
attachedToChart – bool
This signal is emitted when the legend is
attached
to or detached from the chart.- backgroundVisibleChanged(visible)#
- Parameters:
visible – bool
This signal is emitted when the visibility of the legend background changes to
visible
.Notification signal of property
backgroundVisibleᅟ
.- borderColor()#
- Return type:
See also
Getter of property
borderColorᅟ
.This signal is emitted when the border color of the legend background changes to
color
.Notification signal of property
borderColorᅟ
.Returns the brush used by the legend.
See also
- color()#
- Return type:
See also
Getter of property
colorᅟ
.This signal is emitted when the color of the legend background changes to
color
.Notification signal of property
colorᅟ
.- detachFromChart()#
Detaches the legend from the chart. The chart will no longer adjust the layout of the legend.
This signal is emitted when the font of the markers of the legend changes to
font
.Notification signal of property
fontᅟ
.- interactiveChanged(interactive)#
- Parameters:
interactive – bool
- isAttachedToChart()#
- Return type:
bool
Returns
true
, if the legend is attached to a chart.- isBackgroundVisible()#
- Return type:
bool
Returns the visibility of the legend background.
Getter of property
backgroundVisibleᅟ
.- isInteractive()#
- Return type:
bool
Returns whether the legend can be dragged or resized using a mouse when it is detached.
See also
Returns the brush used to draw labels.
See also
- labelColor()#
- Return type:
See also
Getter of property
labelColorᅟ
.This signal is emitted when the color of the brush used to draw the legend labels changes to
color
.Notification signal of property
labelColorᅟ
.- markerShape()#
- Return type:
See also
Getter of property
markerShapeᅟ
.- markerShapeChanged(shape)#
- Parameters:
shape –
MarkerShape
Notification signal of property
markerShapeᅟ
.- markers()#
- Return type:
.list of QLegendMarker
Returns the pen used by the legend.
See also
- reverseMarkers()#
- Return type:
bool
See also
Getter of property
reverseMarkersᅟ
.- reverseMarkersChanged(reverseMarkers)#
- Parameters:
reverseMarkers – bool
This signal is emitted when the use of reverse order for the markers in the legend is changed to
reverseMarkers
.Notification signal of property
reverseMarkersᅟ
.- setAlignment(alignment)#
- Parameters:
alignment – Combination of
AlignmentFlag
See also
Setter of property
alignmentᅟ
.- setBackgroundVisible([visible=true])#
- Parameters:
visible – bool
Sets the visibility of the legend background to
visible
.See also
Setter of property
backgroundVisibleᅟ
.Setter of property
borderColorᅟ
.Sets the
brush
that is used to draw the background of the legend.See also
Setter of property
colorᅟ
.- setInteractive(interactive)#
- Parameters:
interactive – bool
When
interactive
istrue
and the legend is detached, the legend is able to be moved and resized with a mouse in a similar way to a window.The legend will automatically attach to an edge of the chart by dragging it off of that edge. Double clicking an attached legend will detach it. This is
false
by default.See also
Sets the brush used to draw the legend labels to
brush
.See also
Setter of property
labelColorᅟ
.- setMarkerShape(shape)#
- Parameters:
shape –
MarkerShape
See also
Setter of property
markerShapeᅟ
.Sets the
pen
that is used to draw the legend borders.See also
- setReverseMarkers([reverseMarkers=true])#
- Parameters:
reverseMarkers – bool
See also
Setter of property
reverseMarkersᅟ
.- setShowToolTips(show)#
- Parameters:
show – bool
When
show
istrue
, the legend labels will show a tooltip when the mouse hovers over them if the label itself is shown elided. This isfalse
by default.See also
Setter of property
showToolTipsᅟ
.- showToolTips()#
- Return type:
bool
Returns whether the tooltips are shown for the legend labels when they are elided.
See also
Getter of property
showToolTipsᅟ
.- showToolTipsChanged(showToolTips)#
- Parameters:
showToolTips – bool
This signal is emitted when the visibility of tooltips is changed to
showToolTips
.Notification signal of property
showToolTipsᅟ
.