IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)

QLegend Class

L'auteur

Liens sociaux

Viadeo Twitter Facebook Share on Google+   

QLegend Class

  • Header: QLegend

  • Inherited By:

  • Instantiated By: qml-qtcharts-legend.xml

  • Inherits: QGraphicsWidget

  • Inherited By:

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 the QChart class.

Image non disponible

See Also

See also QChart

Member Type Documentation

 

enum QLegend::MarkerShape

This enum describes the shape used when rendering legend marker items.

Constant

Value

Description

QLegend::MarkerShapeDefault

0

Default shape determined by QLegend is used for the marker. This value is supported only for individual QLegendMarker items.

QLegend::MarkerShapeRectangle

1

Rectangular markers are used. Marker size is determined by font size.

QLegend::MarkerShapeCircle

2

Circular markers are used. Marker size is determined by font size.

QLegend::MarkerShapeRotatedRectangle

4

Rotated rectangle shaped markers are used. Marker size is determined by font size.

QLegend::MarkerShapeTriangle

5

Triangular markers are used. Marker size is determined by font size.

QLegend::MarkerShapeStar

6

Star shaped markers are used. Marker size is determined by font size.

QLegend::MarkerShapePentagon

7

Pentagon shaped markers are used. Marker size is determined by font size.

QLegend::MarkerShapeFromSeries

3

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, the lightMarker will be shown and its size will be determined by the series marker size.

See Also

See also markerShape

Property Documentation

 

alignment : Qt::Alignment

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:

  • alignment() const

  • void setAlignment( alignment)

backgroundVisible : bool

This property holds whether the legend background is visible.

Access functions:

Notifier signal:

borderColor : QColor

This property holds the line color of the legend.

Access functions:

  • borderColor()

  • void setBorderColor( color)

Notifier signal:

color : QColor

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:

  • color()

  • void setColor( color)

Notifier signal:

font : QFont

This property holds the font of the markers used by the legend.

Access functions:

  • font() const

  • font() const

  • void setFont(const &font)

  • void setFont(const &font)

Notifier signal:

labelColor : QColor

This property holds the color of the brush used to draw labels.

Access functions:

  • labelColor() const

  • void setLabelColor( color)

Notifier signal:

[since 5.9] markerShape : MarkerShape

The default shape of the legend markers. The default value is MarkerShapeRectangle.

This property was introduced in Qt 5.9.

Access functions:

  • markerShape() const

  • void setMarkerShape( shape)

Notifier signal:

  • void markerShapeChanged( shape)

reverseMarkers : bool

This property holds whether reverse order is used for the markers in the legend.

This property is false by default.

Access functions:

  • bool reverseMarkers()

  • void setReverseMarkers(bool reverseMarkers = true)

Notifier signal:

showToolTips : bool

This property holds whether tooltips are shown when the text is truncated.

This property is false by default.

Access functions:

Notifier signal:

Member Function Documentation

 

[virtual] QLegend::~QLegend()

Destroys the legend object. The legend is always owned by a QChart, so an application should never call this function.

void QLegend::attachToChart()

Attaches the legend to a chart. The chart may adjust the layout of the legend.

[since 6.2] void QLegend::attachedToChartChanged(bool attached)

This signal is emitted when the legend is attached to or detached from the chart.

This function was introduced in Qt 6.2.

void QLegend::backgroundVisibleChanged(bool visible)

This signal is emitted when the visibility of the legend background changes to visible.

Notifier signal for property backgroundVisible.

void QLegend::borderColorChanged(QColor color)

This signal is emitted when the border color of the legend background changes to color.

Notifier signal for property borderColor.

QBrush QLegend::brush() const

Returns the brush used by the legend.

See Also

See also setBrush()

void QLegend::colorChanged(QColor color)

This signal is emitted when the color of the legend background changes to color.

Notifier signal for property color.

void QLegend::detachFromChart()

Detaches the legend from the chart. The chart will no longer adjust the layout of the legend.

void QLegend::fontChanged(QFont font)

This signal is emitted when the font of the markers of the legend changes to font.

Notifier signal for property font.

bool QLegend::isAttachedToChart()

Returns true, if the legend is attached to a chart.

bool QLegend::isBackgroundVisible() const

Returns the visibility of the legend background.

Getter function for property backgroundVisible.

[since 6.2] bool QLegend::isInteractive() const

Returns whether the legend can be dragged or resized using a mouse when it is detached.

This function was introduced in Qt 6.2.

See Also

QBrush QLegend::labelBrush() const

Returns the brush used to draw labels.

See Also

See also setLabelBrush()

void QLegend::labelColorChanged(QColor color)

This signal is emitted when the color of the brush used to draw the legend labels changes to color.

Notifier signal for property labelColor.

QList<QLegendMarker *> QLegend::markers(QAbstractSeries *series = nullptr) const

Returns the list of markers in the legend. The list can be filtered by specifying the series for which the markers are returned.

QPen QLegend::pen() const

Returns the pen used by the legend.

See Also

See also setPen()

void QLegend::reverseMarkersChanged(bool reverseMarkers)

This signal is emitted when the use of reverse order for the markers in the legend is changed to reverseMarkers.

Notifier signal for property reverseMarkers.

void QLegend::setBackgroundVisible(bool visible = true)

Sets the visibility of the legend background to visible.

Setter function for property backgroundVisible.

See Also

See also isBackgroundVisible()

void QLegend::setBrush(const QBrush &brush)

Sets the brush that is used to draw the background of the legend.

See Also

See also brush()

[since 6.2] void QLegend::setInteractive(bool interactive)

When interactive is true 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.

This function was introduced in Qt 6.2.

See Also

void QLegend::setLabelBrush(const QBrush &brush)

Sets the brush used to draw the legend labels to brush.

See Also

See also labelBrush()

void QLegend::setPen(const QPen &pen)

Sets the pen that is used to draw the legend borders.

See Also

See also pen()

void QLegend::setShowToolTips(bool show)

When show is true, the legend labels will show a tooltip when the mouse hovers over them if the label itself is shown elided. This is false by default.

Setter function for property showToolTips.

See Also

See also showToolTips()

bool QLegend::showToolTips() const

Returns whether the tooltips are shown for the legend labels when they are elided.

Getter function for property showToolTips.

See Also

See also setShowToolTips()

void QLegend::showToolTipsChanged(bool showToolTips)

This signal is emitted when the visibility of tooltips is changed to showToolTips.

Notifier signal for property showToolTips.

Vous avez aimé ce tutoriel ? Alors partagez-le en cliquant sur les boutons suivants : Viadeo Twitter Facebook Share on Google+